Point class

From Solid Graphics Wiki

(Redirected from Point)
Jump to: navigation, search
Point class
Namespace: SKL3D
Base type: (None)
Include: Skl3D.h
Lib (Release): SKL.lib
Lib (Debug): SKL_D.lib

The Point class specifies a (x, y, z) location in 3D space using float precision.


Default point class constructor does not initialize the point coordinates to any value. This is on purpose for performance reasons. Other class costructors allow to initialize the point object from other point, or set of three float values, or float values array, or double values array.

See Point class constructors for details.


Field name Type Description
x float the X coordinate
y float the Y coordinate
z float the Z coordinate
coordinates float[ 3 ] array of three (x, y, z) point coordinates. Note: the x, y, z fields and the coordinate array are actually defined as union, so for example code point.coordinate[ 1 ] = 3.0f also changes the point.y coordinate to 3.0f


Method name Description
Transform Transforms point coordinates using given matrix
IsInside The function determines whether the point coordinates are inside of given object (BoundingBox, Shape or Triangle)
Snaps The function returns true if a given point parameter is within bounding box defined by current point location and cSnapDistance library (global) variable.
AlignToGrid Aligns the point location onto a grid defined by given grid size and grid origin.
Scale Multiplies the point coordinates by given scale parameter.
Clamp Clamps point coordinates within given BoundingBox.
SaveToString Saves the point coordinates to given string.
SaveToXML Saves the point coordinates as XML node to given MemoryBuffer.
LoadFromString Loads the point coordinates from given string.
LoadFromXML Reads the point coordinates from given XmlReader.


== Returns true if given points are within a BoundingBox defined by the point and cMinDistance (global) library variable.
!= Returns true if given points are not within a BoundingBox defined by the point and cMinDistance (global) library variable.
+= Adds parameter coordinates to the point.
-= Subtracts parameter coordinates from the point.
*= Multiplies point coordinates by given float constant or transforms point coordinates using given matrix.
/= Divides point coordinates by given float constant.
* Returns new point object which is multiplication of the point by given float constant.
- Unary opertor returns new point object with current point coordinate multiplied by -1.
const float* returns const float pointer to the point coordinates.
float* returns float pointer to the point coordinates.


The Point class does not have any virtual functions on purpose, so it is safe (in MS Visual C++) to typecast pointer to the class object to float pointer and access the x, y, z coordinates by float array indexes 0, 1 and 2.


SKL3D::Point   point;
point.x = 10.0f;
point.y = 15.0f;
point.z = 20.0f;

float* fPtr = ( float* ) & point;
fPtr[ 2 ] = 22.0f;     // this line changes point.z coordinate to 22.0f

Also it is safe to use functions such as memcpy to copy values of one point object to other, or values of point array objects to another point array.

See Also

Personal tools