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¶
|
Set both coordinates of the vec2d |
|
Set the X coordinate (index 0) of the vec2d |
|
Set the Y coordinate (index 1) of the vec2d |
|
Get the X coordinate (index 0) of the vec2d |
|
Get the Y coordinate (index 1) of the vec2d |
Get the magnitude of a vec2d |
|
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
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¶
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Details¶
- openvsp.dist_squared(vec3d a, vec3d b) double[source]¶
- openvsp.dist_squared(vec2d a, vec2d b) double