Vec2D Functions

API functions that utilize the vec2d class are grouped here. For details of the class, including member functions, see vec2d. vec2d is used for the two dimensional problems that come up inside three dimensional ones – parameter space coordinates, projections into a plane, and polygon tests.

vec2d

vec2d.set_xy(xx, yy)

Set both coordinates of the vec2d

vec2d.set_x(xx)

Set the X coordinate (index 0) of the vec2d

vec2d.set_y(yy)

Set the Y coordinate (index 1) of the vec2d

vec2d.x()

Get the X coordinate (index 0) of the vec2d

vec2d.y()

Get the Y coordinate (index 1) of the vec2d

vec2d.mag()

Get the magnitude of a vec2d

vec2d.normalize()

Scale a vec2d to unit length, in place

class openvsp.vec2d(*args)[source]

vec2d is typically used to describe coordinate points and vectors in 2D space. Both elements in the vector are of type double.

property thisown

The membership flag

property v

v : a(2).double

set_xy(xx, yy)[source]

Set both coordinates of the vec2d

a = vec2d()

a.set_xy( 2.0, 4.0 )

assert abs( a.x() - 2.0 ) < 1e-12, "set_xy did not set x"

assert abs( a.y() - 4.0 ) < 1e-12, "set_xy did not set y"

See also: set_x, set_y :param [in]: xx double New X value :param [in]: yy double New Y value :rtype: vec2d :return: vec2d Updated vec2d

set_x(xx)[source]

Set the X coordinate (index 0) of the vec2d

a = vec2d( 0.0, 4.0 )

a.set_x( 2.0 )

assert abs( a.x() - 2.0 ) < 1e-12, "set_x did not set x"

assert abs( a.y() - 4.0 ) < 1e-12, "set_x disturbed y"

See also: set_xy, set_y :param [in]: xx double New X value :rtype: vec2d :return: vec2d Updated vec2d

set_y(yy)[source]

Set the Y coordinate (index 1) of the vec2d

a = vec2d( 2.0, 0.0 )

a.set_y( 4.0 )

assert abs( a.y() - 4.0 ) < 1e-12, "set_y did not set y"

assert abs( a.x() - 2.0 ) < 1e-12, "set_y disturbed x"

See also: set_xy, set_x :param [in]: yy double New Y value :rtype: vec2d :return: vec2d Updated vec2d

x()[source]

Get the X coordinate (index 0) of the vec2d

a = vec2d( 3.0, 4.0 )

assert abs( a.x() - 3.0 ) < 1e-12, "x did not return the X coordinate"

See also: y :rtype: float :return: double X value

y()[source]

Get the Y coordinate (index 1) of the vec2d

a = vec2d( 3.0, 4.0 )

assert abs( a.y() - 4.0 ) < 1e-12, "y did not return the Y coordinate"

See also: x :rtype: float :return: double Y value

mag()[source]

Get the magnitude of a vec2d

a = vec2d( 3.0, 4.0 )

assert abs( a.mag() - 5.0 ) < 1e-12, "mag did not return the magnitude"

See also: normalize :rtype: float :return: double Magnitude

normalize()[source]

Scale a vec2d to unit length, in place

a = vec2d( 3.0, 4.0 )

a.normalize()

assert abs( a.mag() - 1.0 ) < 1e-12, "normalize did not produce a unit vector"

assert abs( a.x() - 0.6 ) < 1e-12, "normalize did not keep the direction"

See also: mag

__rmul__(vec2d self, double b) → vec2d[source]
__len__(vec2d self) → int[source]
__setitem__(i, val)[source]
__repr__(vec2d self) → std::string[source]

Operators

vec2d.__getitem__(other)[source]

Index a vec2d by coordinate, 0 for X and 1 for Y. An index outside that range raises an IndexError, which is also what lets list() and tuple() walk a vec2d.

a = vec2d( 3.0, 4.0 )

assert abs( a[0] - 3.0 ) < 1e-12, "vec2d index 0 is not x"

assert list( a ) == [ 3.0, 4.0 ], "vec2d did not iterate as x, y"

a[1] = 5.0

assert abs( a.y() - 5.0 ) < 1e-12, "vec2d index assignment did not take"
vec2d.__add__(other)[source]

Addition operator for two vec2d objects, performed by the addition of each corresponding component

a = vec2d( 1.0, 2.0 )
b = vec2d( 3.0, 4.0 )

c = a + b

assert abs( c.x() - 4.0 ) < 1e-12, "vec2d addition is wrong in x"

assert abs( c.y() - 6.0 ) < 1e-12, "vec2d addition is wrong in y"
vec2d.__sub__(other)[source]

Subtraction operator for two vec2d objects, performed by the subtraction of each corresponding component

a = vec2d( 3.0, 4.0 )
b = vec2d( 1.0, 2.0 )

c = a - b

assert abs( c.x() - 2.0 ) < 1e-12, "vec2d subtraction is wrong in x"

assert abs( c.y() - 2.0 ) < 1e-12, "vec2d subtraction is wrong in y"
vec2d.__mul__(other)[source]

Scalar multiplication operator for a vec2d, performed by the multiplication of each vec2d component and the scalar

a = vec2d( 1.0, 2.0 )

c = a * 1.5

assert abs( c.x() - 1.5 ) < 1e-12, "vec2d scaling is wrong in x"

assert abs( c.y() - 3.0 ) < 1e-12, "vec2d scaling is wrong in y"
vec2d.__truediv__(other)[source]

Scalar division operator for a vec2d, performed by the division of each vec2d component by the scalar

a = vec2d( 3.0, 6.0 )

c = a / 1.5

assert abs( c.x() - 2.0 ) < 1e-12, "vec2d division is wrong in x"

assert abs( c.y() - 4.0 ) < 1e-12, "vec2d division is wrong in y"

Functions

dist(-> double)

dist_squared(-> double)

cross(-> vec3d)

dot(-> double)

angle(-> double)

cos_angle(-> double)

seg_seg_intersect(vec2d pnt_A, vec2d pnt_B, ...)

proj_pnt_on_line_seg(-> vec3d)

proj_pnt_on_line_u(vec2d line_A, ...)

PointInPolygon(vec2d R, Vec2dVec pnts)

det(vec2d p0, vec2d p1, vec2d offset)

poly_area(-> double)

poly_centroid(Vec2dVec pnt_vec)

orient2d(vec2d p0, vec2d p1, vec2d p)

bi_lin_interp(vec2d p0, vec2d p1, vec2d p2, ...)

inverse_bi_lin_interp(vec2d p0, vec2d p1, ...)

Details

openvsp.dist(vec3d a, vec3d b) → double[source]
openvsp.dist(vec2d a, vec2d b) → double
openvsp.dist_squared(vec3d a, vec3d b) → double[source]
openvsp.dist_squared(vec2d a, vec2d b) → double
openvsp.cross(vec3d a, vec3d b) → vec3d[source]
openvsp.cross(vec2d a, vec2d b) → double
openvsp.dot(vec3d a, vec3d b) → double[source]
openvsp.dot(vec2d a, vec2d b) → double
openvsp.angle(vec3d a, vec3d b) → double[source]
openvsp.angle(vec2d a, vec2d b) → double
openvsp.cos_angle(vec3d a, vec3d b) → double[source]
openvsp.cos_angle(vec2d a, vec2d b) → double
openvsp.seg_seg_intersect(vec2d pnt_A, vec2d pnt_B, vec2d pnt_C, vec2d pnt_D) → int[source]
openvsp.proj_pnt_on_line_seg(vec3d line_pt1, vec3d line_pt2, vec3d pnt) → vec3d[source]
openvsp.proj_pnt_on_line_seg(vec2d line_A, vec2d line_B, vec2d pnt) → vec2d
openvsp.proj_pnt_on_line_u(vec2d line_A, vec2d line_B, vec2d pnt) → double[source]
openvsp.PointInPolygon(vec2d R, Vec2dVec pnts) → bool[source]
openvsp.det(vec2d p0, vec2d p1, vec2d offset) → double[source]
openvsp.poly_area(Vec3dVec pnt_vec) → double[source]
openvsp.poly_area(Vec2dVec pnt_vec) → double
openvsp.poly_centroid(Vec2dVec pnt_vec) → vec2d[source]
openvsp.orient2d(vec2d p0, vec2d p1, vec2d p) → double[source]
openvsp.bi_lin_interp(vec2d p0, vec2d p1, vec2d p2, vec2d p3, double s, double t)[source]
openvsp.inverse_bi_lin_interp(vec2d p0, vec2d p1, vec2d p2, vec2d p3, vec2d p) → int[source]