[Integration Kit Contents] [Integration Kit What's New] [Integration Kit Function Index] [More Documentation] [PTC]

Arithmetical and Vector Utilities

gpnt3d
gpnt2d
sd-gpnt3d-to-2d

sd-num-equal-p
sd-deg-to-rad
sd-rad-to-deg

sd-vec-null-p
sd-vec-equal-p
sd-vec-colinear-p
sd-vec-dir-equal-p
sd-vec-add
sd-vec-subtract
sd-vec-scale
sd-vec-normalize
sd-vec-cross-product
sd-vec-scalar-product
sd-vec-length
sd-vec-angle-between

sd-vec-translate
sd-vec-rotate
sd-vec-xform
sd-dir-rotate
sd-dir-xform
sd-box-points

GPNT3D  [structure]

(make-gpnt3d :x x
             :y y
             :z z)
(copy-gpnt3d gpnt3d)
(gpnt3d-p gpnt3d)
(gpnt3d_x gpnt3d)
(gpnt3d_y gpnt3d)
(gpnt3d_z gpnt3d)

Description:
The structure used to represent the x,y,z coordinates of a 3d point or vector.

Slots:
x {LONG-FLOAT [0.0]} - the x coordinate of the 3d vector
y {LONG-FLOAT [0.0]} - the y coordinate of the 3d vector
z {LONG-FLOAT [0.0]} - the z coordinate of the 3d vector

Function Index Top of Page

GPNT2D  [structure]

(make-gpnt2d :x x :y y)
(copy-gpnt2d vec2d)
(gpnt2d-p gpnt3d)
(gpnt2d_x vec2d)
(gpnt2d_y vec2d)
Description:
The structure used to represent the x,y coordinates of a 2d point or vector.

Slots:
x {LONG-FLOAT [0.0]} - the x coordinate of the 2d vector
y {LONG-FLOAT [0.0]} - the y coordinate of the 2d vector

Function Index Top of Page

SD-GPNT3D-TO-2D  [function]

(sd-gpnt3d-to-2d gpnt3d)
Description:
Converts a GPNT3D (3D point or vector) to a GPNT2D by eliminating the z component.

Parameters:
gpnt3d {GPNT3D} - the 3D point or vector

Return value:
gpnt2d {GPNT2D} - the gpnt2d

Function Index Top of Page

SD-NUM-EQUAL-P  [function]

(sd-num-equal-p num1 num2 :resolution resolution)
Description:
Checks if the two passed numbers are equal within the specified geometric resolution.

Parameters:
num1 {NUMBER}
The first number (integer of float) for the check.
num2 {NUMBER}
The second number (integer of float) for the check.
:resolution {LONG-FLOAT [System-default-resolution]}
The geometric resolution (or accuracy).

Return value:
t - if the absolute difference between both numbers is less than resolution
nil - otherwise

Function Index Top of Page

SD-DEG-TO-RAD  [macro]

(sd-deg-to-rad angle)
Description:
Converts an angle given in degree to an angle in radians.

Parameters:
angle {LONG-FLOAT} - the angle in degree

Return value:
angle {LONG-FLOAT} - the angle in radians

Function Index Top of Page

SD-RAD-TO-DEG  [macro]

(sd-rad-to-deg angle)
Description:
Converts an angle given in radians to an angle in degree.

Parameters:
angle {LONG-FLOAT} - the angle in radians

Return value:
angle {LONG-FLOAT} - the angle in degree

Function Index Top of Page

SD-VEC-NULL-P  [function]

(sd-vec-null-p vector
               :resolution resolution)
Description:
Checks if a vector is equivalent to the null vector (0,0 or 0,0,0) within the specified geometric resolution (or the default resolution of 1e-6). Note that the default resolution is a fixed constant, and is not affected by the system setting for default geometric resolution.

Parameters:
vector {GPNT3D or GPNT2D}
The vector to check against the null vector.
:resolution {NUMBER [1e-6]}
The geometric resolution (or accuracy).

Return value:
t - if the vector is null
nil - if the vector is not null

Function Index Top of Page

SD-VEC-EQUAL-P  [function]

(sd-vec-equal-p vector1 vector2
                :resolution resolution)
Description:
Checks if the difference between two vectors is equivalent to the null vector (0,0 or 0,0,0) within the specified geometric resolution (or the default resolution of 1e-6). Note that the default resolution is a fixed constant, and is not affected by the system setting for default geometric resolution.

Parameters:
vector1 and vector2 {GPNT3D or GPNT2D}
The vectors to compare. If the vectors are not of the same type, then the GPNT2D vector is treated as a GPNT3D vector with a zero value Z-coordinate.
:resolution {NUMBER [1e-6]}
The geometric resolution (accuracy).

Return value:
t - if the vectors are equal
nil - if the vectors are not equal

See Also:
sd-inq-default-geo-resolution
sd-inq-part-geo-resolution

Function Index Top of Page

SD-VEC-COLINEAR-P  [function]

(sd-vec-colinear-p vector1 vector2)
Description:
Checks if two vectors are colinear.

Parameters:
vector1 and vector2 {GPNT2D or GPNT3D}
The vectors to compare. If the vectors are not of the same type, then the GPNT2D vector is treated as a GPNT3D vector with a zero value Z-coordinate.

Return value:
t - if the vectors are colinear
nil - if the vectors are not colinear

Function Index Top of Page

SD-VEC-DIR-EQUAL-P  [function]

(sd-vec-dir-equal-p vector1 vector2)
Description:
Checks if the direction of the passed vectors is the same.

Parameters:
vector1 and vector2 {GPNT2D or GPNT3D}
The vectors to compare. If the vectors are not of the same type, then the GPNT2D vector is treated as a GPNT3D vector with a zero value Z-coordinate.

Return value:
t - if the vectors have the same direction
nil - if the vectors have different directions

Function Index Top of Page

SD-VEC-ADD  [function]

(sd-vec-add vector1 vector2)
Description:
Adds two vectors.

Parameters:
vector1 and vector2 {GPNT2D or GPNT3D}
The vectors to add. If the vectors are not of the same type, then the GPNT2D vector is treated as a GPNT3D vector with a zero value Z-coordinate.

Return value:
sum {GPNT2D or GPNT3D} - The sum of vector1 and vector2

Function Index Top of Page

SD-VEC-SUBTRACT  [function]

(sd-vec-subtract vector1 vector2)
Description:
Subtracts vector2 from vector1.

Parameters:
vector1 and vector2 {GPNT2D or GPNT3D}
The vectors to subtract. If the vectors are not of the same type, then the GPNT2D vector is treated as a GPNT3D vector with a zero value Z-coordinate.

Return value:
difference {GPNT2D or GPNT3D}
The subtraction of vector2 from vector1 (in other words, the direction vector pointing from vector2 to vector1).

Function Index Top of Page

SD-VEC-SCALE  [function]

(sd-vec-scale vector scalar)
Description:
Multiplies each component of vector by scalar.

Parameters:
vector {GPNT2D or GPNT3D}
The vector to scale.
scalar {NUMBER}
The scaling factor.

Return value:
dot product {GPNT2D or GPNT3D}
The result of multiplying each component of vector by scalar

Function Index Top of Page

SD-VEC-NORMALIZE  [function]

(sd-vec-normalize vector)
Description:
Converts vector to a unit vector (i.e. scales it such that it's length equals 1.0).

Parameters:
vector {GPNT2D or GPNT3D} - must NOT be a null vector!
The vector to normalize.

Return value:
normalized vector{GPNT2D or GPNT3D} - The normalized vector.

Function Index Top of Page

SD-VEC-CROSS-PRODUCT  [function]

(sd-vec-cross-product vector1 vector2)
Description:
Calculates the cross product of vector1 and vector2.

Parameters:
vector1 and vector2 {GPNT2D or GPNT3D}
The vectors to cross.

Return value:
cross product {GPNT3D} - The cross product.

Function Index Top of Page

SD-VEC-SCALAR-PRODUCT  [function]

(sd-vec-scalar-product vector1 vector2)
Description:
Calculates the scalar product of vector1 and vector2.

Parameters:
vector1 and vector2 {GPNT2D or GPNT3D}

Return value:
scalar product {LONG-FLOAT} - The scalar product.

Function Index Top of Page

SD-VEC-LENGTH  [function]

(sd-vec-length vector)
Description:
Calculates the length of vector.

Parameters:
vector {GPNT2D or GPNT3D}

Return value:
length {LONG-FLOAT}

Function Index Top of Page

SD-VEC-ANGLE-BETWEEN  [function]

(sd-vec-angle-between vector1 vector2)
Description:
Calculates the angle (in radians) from vector1 to vector2. The sense of the angle is such that vector1 can be made colinear with vector2 if rotated by angle about the axis given by the cross product vector1 x vector2.
If both vectors are 2D vectors the resulting angle is in the range between 0 and 2pi. In this special case there is no need to calculate the cross product.

Parameters:
vector1 and vector2 {GPNT2D or GPNT3D} - neither may be a null vector!

Return value:
angle {LONG-FLOAT} - the angle in radians

Function Index Top of Page

SD-VEC-TRANSLATE  [function]

(sd-vec-translate vector direction length)
Description:
Translates vector in the direction direction about length.

Parameters:
vector {GPNT3D} - the vector to translate
direction {GPNT3D} - the translation direction
length {LONG-FLOAT} - the amount to translate

Return value:
vector {GPNT3D} - the translated vector

Function Index Top of Page

SD-VEC-ROTATE  [function]

(sd-vec-rotate vector angle :point point :direction direction)
Description:
Rotates vector around the axis specified though :point and :direction about angle.

Parameters:
vector {GPNT3D} - the vector to rotate
angle {LONG-FLOAT} - the rotation angle in radians
:point {GPNT3D [0,0,0]} - a point on the rotation axis
:direction {GPNT3D} - the direction of the rotation axis

Return value:
vector {GPNT3D} - the rotated vector

Function Index Top of Page

SD-VEC-XFORM  [function]

(sd-vec-xform vector :source-space source-space :dest-space dest-space)
Description:
Transforms a vector specified in the source-space coordinate system into the dest-space coordinate system.

Parameters:
vector {GPNT2D or GPNT3D} - the vector to transform
:source-space {KEYWORD or SEL_ITEM} - the source coordinate system
:global - vector is defined in the global coordinate system
SEL_ITEM - Represents either an object or an element. vector is defined in the coordinate system of the object or part/workplane owning the element.
:dest-space {KEYWORD or SEL_ITEM [:global]} - the destination coordinate system
:global - vector will be transformed into the global coordinate system
SEL_ITEM - Represents either an object or an element. vector is transformed into the coordinate system of the object or part/workplane owning the element.

Return value:
vector {GPNT3D} - the transformed vector

Function Index Top of Page

SD-DIR-ROTATE  [function]

(sd-dir-rotate direction angle :point point :direction direction)
Description:
Rotates direction around the axis specified though :point and :direction about angle.

Parameters:
direction {GPNT3D} - the direction vector to rotate
angle {LONG-FLOAT} - the rotation angle in radians
:point {GPNT3D [0,0,0]} - a point on the rotation axis
:direction {GPNT3D} - the direction of the rotation axis

Return value:
direction {GPNT3D} - the rotated direction vector

Function Index Top of Page

SD-DIR-XFORM  [function]

(sd-dir-xform direction :source-space source-space :dest-space dest-space)
Description:
Transforms a direction vector specified in the source-space coordinate system into the dest-space coordinate system.

Parameters:
direction {GPNT2D or GPNT3D} - the direction vector to transform
:source-space {KEYWORD or SEL_ITEM} - the source coordinate system
:global - the direction vector is defined in the global coordinate system
SEL_ITEM - Represents either an object or an element. The direction vector is defined in the coordinate system of the object or part/workplane owning the element.
:dest-space {KEYWORD or SEL_ITEM [:global]} - the destination coordinate system
:global - the direction vector will be transformed into the global coordinate system
SEL_ITEM - Represents either an object or an element. The direction vector is transformed into the coordinate system of the object or part/workplane owning the element.

Return value:
direction {GPNT3D} - the transformed direction vector

Function Index Top of Page

SD-BOX-POINTS  [function]

(sd-box-points lower-left upper-right z-dir x-dir)
Description:
Calculate the corner points of a box given by the lower left and upper right point and the axis directions x, y, z, where x is given by x-dir, y by the cross product of z and x and z is given by z-dir

Parameters:
lower-left {GPNT3D} - the lower left point of the box
upper-right {GPNT3D} - the upper right point of the box
z-dir {GPNT3D} - the z direction of the box
x-dir {GPNT3D} - the x direction of the box

Return value:
result {LIST} - a list containing the 8 corner points of the box as described in SD-START-BOX-FEEDBACK, so that the result can directly be used by the feedback function
[Integration Kit Contents] [Integration Kit What's New] [Integration Kit Function Index] [More Documentation] [PTC]
© 2023 Parametric Technology GmbH
(a subsidiary of PTC Inc.), All Rights Reserved