124 SbVec3f() { vec[0] = 0.f; vec[1] = 0.f; vec[2] = 0.f; }
128 { vec[0] = v[0]; vec[1] = v[1]; vec[2] = v[2]; }
132 { vec[0] = x; vec[1] = y; vec[2] = z; }
160 { vec[0] = v[0]; vec[1] = v[1]; vec[2] = v[2];
return *
this; }
164 { vec[0] = x; vec[1] = y; vec[2] = z;
return *
this; }
172 float & operator [](
int i) {
return (vec[i]); }
173 const float & operator [](
int i)
const {
return (vec[i]); }
180 {
return *
this *= (1.0f / d); }
220{
return v * (1.0f / d); }
226{
return !(v1 == v2); }
283 float & operator [](
int i) {
return (vec[i]); }
284 const float & operator [](
int i)
const {
return (vec[i]); }
291 {
return *
this *= (1.0f / d); }
327{
return v * (1.0f / d); }
335{
return !(v1 == v2); }
385 short & operator [](
int i) {
return (vec[i]); }
386 const short & operator [](
int i)
const {
return (vec[i]); }
397 {
return *
this *= (1.0 / d); }
436{
return v * (1.0 / d); }
443{
return !(v1 == v2); }
458 SbVec3s() { vec[0] = 0; vec[1] = 0; vec[2] = 0; }
464 SbVec3s(
short x,
short y,
short z) { setValue(x, y, z); }
485 short & operator [](
int i) {
return (vec[i]); }
486 const short & operator [](
int i)
const {
return (vec[i]); }
494 {
return *
this *= (1.0 / d); }
534{
return v * (1.0 / d); }
541{
return !(v1 == v2); }
563 SbVec4f() { vec[0] = 0.f; vec[1] = 0.f; vec[2] = 0.f; vec[3] = 0.f; }
569 SbVec4f(
float x,
float y,
float z,
float w) { setValue(x, y, z, w); }
584 void getValue(
float &x,
float &y,
float &z,
float &w)
const;
602 float & operator [](
int i) {
return (vec[i]); }
603 const float & operator [](
int i)
const {
return (vec[i]); }
610 {
return *
this *= (1.0f / d); }
646{
return v * (1.0f / d); }
654{
return !(v1 == v2); }
683 { quat[0] = 0.f; quat[1] = 0.f; quat[2] = 0.f; quat[3] = 1.f; }
691 { setValue(q0, q1, q2, q3); }
699 { setValue(axis, radians); }
711 { setValue(rotateFrom, rotateTo); }
719 float &q2,
float &q3)
const;
733 float getAngle()
const {
SbVec3f axis;
float radians; getValue(axis, radians);
return radians; }
803{
return !(q1 == q2); }
832 SbMatrix(
float a11,
float a12,
float a13,
float a14,
833 float a21,
float a22,
float a23,
float a24,
834 float a31,
float a32,
float a33,
float a34,
835 float a41,
float a42,
float a43,
float a44);
880 { setTransform(t, r, s,
884 { setTransform(t, r, s, so,
SbVec3f(0,0,0)); }
900 { getTransform(t, r, s, so,
SbVec3f(0,0,0)); }
911 float det3(
int r1,
int r2,
int r3,
int c1,
int c2,
int c3)
const;
914 float det3()
const {
return det3(0, 1, 2, 0, 1, 2); }
995 operator float *() {
return &matrix[0][0]; }
998 operator SbMat &() {
return matrix; }
1001 float * operator [](
int i) {
return &matrix[i][0]; }
1002 const float * operator [](
int i)
const {
return &matrix[i][0]; }
1030 void jacobi3(
float evalues[3],
SbVec3f evectors[3],
int &rots)
const;
1039{
return !(m1 == m2); }
1123 const SbVec2f &normPoint)
const;
1136 float normRadius)
const;
1148 float right,
float top)
const;
1158 float bottom,
float top,
1159 float nearVal,
float farVal);
1166 float nearVal,
float farVal);
1224 float getWidth()
const {
return (lrfO-llfO).length(); }
1334 bool &front )
const;
1417{
return !(p1 == p2); }
1466 static bool unitCylinderIntersect(
const SbLine &l,
INVENTOR_API bool operator!=(const SbBox3f &b1, const SbBox3f &b2)
INVENTOR_API bool operator==(const SbBox3f &b1, const SbBox3f &b2)
INVENTOR_API SbVec3f operator-(const SbVec3f &v1, const SbVec3f &v2)
INVENTOR_API SbVec3f operator/(const SbVec3f &v, float d)
INVENTOR_API bool operator==(const SbVec3f &v1, const SbVec3f &v2)
INVENTOR_API SbVec3f operator*(const SbVec3f &v, float d)
INVENTOR_API bool operator!=(const SbVec3f &v1, const SbVec3f &v2)
INVENTOR_API SbVec3f operator+(const SbVec3f &v1, const SbVec3f &v2)
#define INVENTOR_API
Disable some annoying warnings on MSVC 6.
Class for representing a cylinder.
SbCylinder(const SbLine &a, float r)
Create cylinder from axis and radius.
bool intersect(const SbLine &l, SbVec3f &intersection) const
Intersect line and cylinder, returning TRUE if there is an intersection.
void setAxis(const SbLine &a)
Set just the axis or radius.
void setRadius(float r)
Set just the axis or radius.
void setValue(const SbLine &a, float r)
Change the axis and radius.
SbCylinder()
Default Constructor.
const SbLine & getAxis() const
Return the axis and radius.
float getRadius() const
Return the axis and radius.
bool intersect(const SbLine &l, SbVec3f &enter, SbVec3f &exit) const
bool intersect(float angle, const SbVec3f &v0, const SbVec3f &v1, SbVec3f &pt) const
bool intersect(float angle, const SbVec3f &point) const
const SbVec3f & getDirection() const
Returns position of line origin point and direction vector of line.
bool intersect(const SbVec3f &v0, const SbVec3f &v1, const SbVec3f &v2, SbVec3f &pt, SbVec3f &barycentric, bool &front) const
bool intersect(float angle, const SbBox3f &box) const
bool intersect(const SbBox3f &box, SbVec3f &enter, SbVec3f &exit) const
Intersect the line with a box, point, line, and triangle.
const SbVec3f & getPosition() const
Returns position of line origin point and direction vector of line.
SbVec3f getClosestPoint(const SbVec3f &point) const
Returns the closest point on the line to the given point.
void setValue(const SbVec3f &p0, const SbVec3f &p1)
Sets line to pass through points p0 and p1.
bool getClosestPoints(const SbLine &line2, SbVec3f &ptOnThis, SbVec3f &ptOnLine2) const
Finds the two closest points between this line and line2, and loads them into ptOnThis and ptOnLine2.
SbLine(const SbVec3f &p0, const SbVec3f &p1)
Constructors.
bool factor(SbMatrix &r, SbVec3f &s, SbMatrix &u, SbVec3f &t, SbMatrix &proj) const
Factors a matrix m into 5 pieces: m = r s r^ u t, where r^ means transpose of r, and r and u are rota...
SbMatrix(float a11, float a12, float a13, float a14, float a21, float a22, float a23, float a24, float a31, float a32, float a33, float a34, float a41, float a42, float a43, float a44)
Constructor given all 16 elements in row-major order.
void LUBackSubstitution(int index[4], float b[4]) const
Perform back-substitution on LU-decomposed matrix.
void multVecMatrix(const SbVec4f &src, SbVec4f &dst) const
Multiplies given row vector by matrix, giving vector result. Takes homogenous coordinate and returns ...
void setScale(const SbVec3f &s)
Sets matrix to scale by given vector.
void multLineMatrix(const SbLine &src, SbLine &dst) const
Multiplies the given line's origin by the matrix, and the line's direction by the rotation portion of...
void multVecMatrix(const SbVec3f &src, SbVec4f &dst) const
Multiplies given row vector by matrix, giving vector result. Takes SbVec4(src,1.f) coordinate and ret...
void setTransform(const SbVec3f &t, const SbRotation &r, const SbVec3f &s, const SbRotation &so)
float det4() const
Returns determinant of entire matrix.
float det3() const
Returns determinant of upper-left 3x3 submatrix.
SbMatrix()
Default constructor, initialized to identity.
void getTransform(SbVec3f &translation, SbRotation &rotation, SbVec3f &scaleFactor, SbRotation &scaleOrientation, const SbVec3f ¢er) const
Decomposes the matrix into a translation, rotation, scale, and scale orientation.
void getTransform(SbVec3f &t, SbRotation &r, SbVec3f &s, SbRotation &so) const
void setValue(const float *data)
Sets value from a float array of 16 elements.
void print(FILE *fp) const
Prints a formatted version of the matrix to the given file pointer.
bool LUDecomposition(int index[4], float &d)
Perform in-place LU decomposition of matrix.
static SbMatrix identity()
Returns an identity matrix.
void setValue(const SbMat &m)
Sets value from 4x4 array of elements.
void setScale(float s)
Sets matrix to scale by given uniform factor.
void multDirMatrix(const SbVec3f &src, SbVec3f &dst) const
Multiplies given row vector by matrix, giving vector result.
const SbMat & getValue() const
SbMatrix & multRight(const SbMatrix &m)
Multiplies matrix by given matrix on right or left.
SbVec4f transformPoint(const SbVec4f &src) const
Multiplies given row vector by matrix, giving vector result. Takes homogenous coordinate and returns ...
void setTranslate(const SbVec3f &t)
Sets matrix to translate by given vector.
SbMatrix & multLeft(const SbMatrix &m)
Multiplies matrix by given matrix on right or left.
SbVec3f transformDirection(const SbVec3f &src) const
Multiplies given row vector by matrix, giving vector result.
void setTransform(const SbVec3f &translation, const SbRotation &rotation, const SbVec3f &scaleFactor, const SbRotation &scaleOrientation, const SbVec3f ¢er)
Composes the matrix based on a translation, rotation, scale, orientation for scale,...
float det3(int r1, int r2, int r3, int c1, int c2, int c3) const
Returns determinant of 3x3 submatrix composed of given row and column indices (0-3 for each).
bool equals(const SbMatrix &m, float tolerance) const
Equality comparison within given tolerance, for each component.
void makeIdentity()
Sets matrix to be identity.
void setTransform(const SbVec3f &t, const SbRotation &r, const SbVec3f &s)
Overloaded methods as a kludge because the compiler won't let us have SbVec3f(0,0,...
SbLine transformLine(const SbLine &src) const
Multiplies the given line's origin by the matrix, and the line's direction by the rotation portion of...
SbMatrix transpose() const
Returns transpose of matrix.
void multVecMatrix(const SbVec3f &src, SbVec3f &dst) const
Multiplies given row vector by matrix, giving vector result. Use this method to transform points from...
void setRotate(const SbRotation &q)
Sets matrix to rotate by given rotation.
SbMatrix(const SbMat &m)
Constructors.
void multMatrixVec(const SbVec3f &src, SbVec3f &dst) const
Multiplies matrix by given column vector, giving vector result.
SbMatrix inverse() const
Returns inverse of matrix.
SbVec3f transformPoint(const SbVec3f &src) const
Multiplies given row vector by matrix, giving vector result. Use this method to transform points from...
void getValue(SbMat &m) const
The following methods return matrix values and other info:
SbPlane(const SbVec3f &n, float d)
Construct a plane given normal and distance from origin along normal.
bool intersect(const SbLine &l, SbVec3f &intersection) const
Intersect line and plane, returning TRUE if there is an intersection, FALSE if line is parallel to pl...
float getDistanceFromOrigin() const
Returns distance from origin to plane.
float getDistance(const SbVec3f &point) const
Returns the distance of the point to the plane.
void transform(const SbMatrix &matrix)
Transforms the plane by the given matrix.
SbPlane()
Default constructor.
bool isInHalfSpace(const SbVec3f &point) const
Returns TRUE if the given point is within the half-space defined by the plane.
SbPlane(const SbVec3f &n, const SbVec3f &p)
Construct a plane given normal and a point to pass through Orientation is given by the normal vector ...
void offset(float d)
Offset a plane by a given distance.
const SbVec3f & getNormal() const
Returns normal vector to plane.
SbPlane(const SbVec3f &p0, const SbVec3f &p1, const SbVec3f &p2)
Construct a plane given three points.
Class for representing a rotation.
SbRotation & setValue(const SbVec3f &rotateFrom, const SbVec3f &rotateTo)
Sets rotation to rotate one direction vector to another.
SbRotation()
Default constructor, initialized to identity.
static SbRotation slerp(const SbRotation &rot0, const SbRotation &rot1, float t)
Spherical linear interpolation: as t goes from 0 to 1, returned value goes from rot0 to rot1.
void getValue(SbMatrix &matrix) const
Returns corresponding 4x4 rotation matrix.
SbVec3f getAxis() const
Returns corresponding 3D rotation axis vector.
bool equals(const SbRotation &r, float tolerance) const
Equality comparison within given tolerance em the square of the length of the maximum distance betwee...
SbRotation & setValue(const SbMatrix &m)
Sets value of rotation from a rotation matrix.
SbRotation & setValue(const float q[4])
Sets value of rotation from array of 4 components of a quaternion.
SbVec3f transformPoint(const SbVec3f &src) const
Multiplies the given vector by the matrix of this rotation.
void getValue(SbVec3f &axis, float &radians) const
Returns corresponding 3D rotation axis vector and angle in radians.
SbRotation(const SbVec3f &rotateFrom, const SbVec3f &rotateTo)
Constructors for rotation.
SbRotation(float q0, float q1, float q2, float q3)
SbRotation & setValue(float q0, float q1, float q2, float q3)
Sets value of rotation from 4 individual components of a quaternion.
SbRotation & setValue(const SbVec3f &axis, float radians)
Sets value of vector from 3D rotation axis vector and angle in radians.
void scaleAngle(float scaleFactor)
Keep the axis the same.
SbMatrix getMatrix() const
Returns corresponding 4x4 rotation matrix.
void multVec(const SbVec3f &src, SbVec3f &dst) const
Multiplies the given vector by the matrix of this rotation.
float getAngle() const
Returns corresponding angle in radians.
SbRotation(const SbVec3f &axis, float radians)
SbRotation(const SbMatrix &m)
void getValue(float &q0, float &q1, float &q2, float &q3) const
Returns 4 individual components of rotation quaternion.
SbRotation(const float v[4])
SbRotation & invert()
Changes a rotation to be its inverse.
const float * getValue() const
Returns pointer to array of 4 components defining quaternion.
SbRotation inverse() const
Returns the inverse of a rotation.
static SbRotation identity()
Returns a null rotation.
Class for representing a sphere.
void setRadius(float r)
Set just the center or radius.
void circumscribe(const SbBox3f &box)
Return a sphere containing a given box.
void setValue(const SbVec3f &c, float r)
Change the center and radius.
void setCenter(const SbVec3f &c)
Set just the center or radius.
SbSphere(const SbVec3f &c, float r)
Construct a sphere given center and radius.
float getRadius() const
Return the center and radius.
bool intersect(const SbLine &l, SbVec3f &enter, SbVec3f &exit) const
bool intersect(const SbLine &l, SbVec3f &intersection) const
Intersect line and sphere, returning TRUE if there is an intersection.
const SbVec3f & getCenter() const
Return the center and radius.
SbVec2f & setValue(float x, float y)
Sets the vector components.
float normalize()
Changes vector to be unit length.
bool equals(const SbVec2f v, float tolerance) const
Equality comparison within given tolerance em the square of the length of the maximum distance betwee...
const float * getValue() const
Returns vector components.
SbVec2f()
Default constructor.
void negate()
Negates each component of vector in place.
void getValue(float &x, float &y) const
Returns vector components.
SbVec2f & setValue(const float v[2])
Sets the vector components.
SbVec2f(float x, float y)
Constructor given vector components.
float dot(const SbVec2f &v) const
Returns dot (inner) product of vector and another vector.
float length() const
Returns geometric length of vector.
SbVec2f(const float v[2])
Constructor given vector components.
SbVec2s(short x, short y)
Constructor given 2 components.
void getValue(short &x, short &y) const
Returns vector components.
SbVec2s()
Default constructor.
SbVec2s & setValue(const short v[2])
Sets vector components.
SbVec2s & setValue(short x, short y)
Sets vector components.
SbVec2s(const short v[2])
Constructor given 2 components.
void negate()
Negates each component of vector in place.
const short * getValue() const
Returns vector components.
int32_t dot(const SbVec2s &v) const
Returns dot (inner) product of vector and another vector.
SbVec3f cross(const SbVec3f &v) const
Returns right-handed cross product of vector and another vector.
float length() const
Returns geometric length of vector.
float normalize()
Changes vector to be unit length, returning the length before normalization.
SbVec3f & setValue(const SbVec3f &barycentic, const SbVec3f &v0, const SbVec3f &v1, const SbVec3f &v2)
Sets value of vector to be convex combination of 3 other vectors, using barycentic coordinates.
SbVec3f & setValue(const float v[3])
Sets the vector components.
void getValue(float &x, float &y, float &z) const
Returns vector components.
SbVec3f(const float v[3])
Constructor given vector components.
SbVec3f(SbPlane &p0, SbPlane &p1, SbPlane &p2)
Constructor given 3 planes.
bool equals(const SbVec3f v, float tolerance) const
Equality comparison within given tolerance em the square of the length of the maximum distance betwee...
float dot(const SbVec3f &v) const
Returns dot (inner) product of vector and another vector.
void negate()
Negates each component of vector in place.
SbVec3f(float x, float y, float z)
Constructor given vector components.
const float * getValue() const
Returns vector components.
SbVec3f & setValue(float x, float y, float z)
Sets the vector components.
SbVec3f()
Default constructor.
SbVec3f getClosestAxis() const
Returns principal axis that is closest (based on maximum dot product) to this vector.
3D vector used to represet points or directions.
SbVec3s & setValue(const short v[3])
Sets value of vector from array of 3 components.
SbVec3s(const short v[3])
Constructor given an array of 3 components.
void getValue(short &x, short &y, short &z) const
Returns vector components.
void negate()
Negates each component of vector in place.
const short * getValue() const
Returns vector components.
int32_t dot(const SbVec3s &v) const
Returns dot (inner) product of vector and another vector.
SbVec3s()
Default constructor.
SbVec3s(short x, short y, short z)
Constructor given 3 individual components.
SbVec3s & setValue(short x, short y, short z)
Sets value of vector from 3 individual components.
float length() const
Returns geometric length of vector.
void negate()
Negates each component of vector in place.
float normalize()
Changes vector to be unit length.
SbVec4f & setValue(const float v[4])
Sets the vector components.
void getReal(SbVec3f &v) const
Returns the real portion of the vector by dividing by the fourth value.
const float * getValue() const
Returns vector components.
SbVec4f & setValue(float x, float y, float z, float w)
Sets the vector components.
void getValue(float &x, float &y, float &z, float &w) const
Returns vector components.
SbVec3f getReal() const
Returns the real portion of the vector by dividing by the fourth value.
SbVec4f(const float v[4])
Constructor given vector components.
SbVec4f()
Default constructor.
SbVec4f(float x, float y, float z, float w)
Constructor given vector components.
float dot(const SbVec4f &v) const
Returns dot (inner) product of vector and another vector.
bool equals(const SbVec4f v, float tolerance) const
Equality comparison within given tolerance em the square of the length of the maximum distance betwee...
float nearDist
distance to near plane
void transform(const SbMatrix &matrix)
Transforms the view volume by the given matrix.
const SbVec3f & getProjectionPoint() const
Returns projection information.
void projectPointToLine(const SbVec2f &pt, SbLine &line) const
Maps a 2d point (in 0 <= x,y <= 1) to a 3d line.
ProjectionType getProjectionType() const
Returns projection information.
void ortho(float left, float right, float bottom, float top, float nearVal, float farVal)
Sets up an orthographic view volume with the given sides.
SbRotation getAlignRotation(bool rightAngleOnly=FALSE) const
Returns a rotation that would align a viewed object so that its positive x-axis (of its object space)...
void getMatrices(SbMatrix &affine, SbMatrix &proj) const
Returns two matrices corresponding to the view volume.
float getDepth() const
Returns bounds of viewing frustum.
SbViewVolume()
Constructor and destructor.
float getWorldToScreenScale(const SbVec3f &worldCenter, float normRadius) const
Returns a scale factor that would scale a unit sphere centered at worldCenter so that it would appear...
bool intersect(const SbVec3f &p0, const SbVec3f &p1, SbVec3f &closestPoint) const
Returns TRUE if line segment between 2 points may intersect volume.
void projectToScreen(const SbVec3f &src, SbVec3f &dst) const
Maps the 3D point in world coordinates to a 2D point in normalized screen coordinates (0 <= x,...
SbViewVolume narrow(const SbBox3f &box) const
Narrow a view volume by the given box.
SbMatrix getProjectionMatrix() const
Returns the projection matrix.
float nearToFar
distance between z clips
ProjectionType
Return projection information.
SbVec3f projectToScreen(const SbVec3f &src) const
Maps the 3D point in world coordinates to a 2D point in normalized screen coordinates (0 <= x,...
void translateCamera(const SbVec3f &v)
Translate the camera viewpoint.
void rotateCamera(const SbRotation &q)
Rotate the camera view direction.
void scale(float factor)
Scales width and height of view volume by given factor.
SbViewVolume narrow(float left, float bottom, float right, float top) const
Given a view volume, this narrows the view to the given sub-rectangle of the near plane.
void scaleHeight(float ratio)
Scales view volume to be the given ratio of its current height, leaving the resulting view volume cen...
float getHeight() const
Returns bounds of viewing frustum.
SbVec3f getPlanePoint(float distFromEye, const SbVec2f &normPoint) const
Returns the projection of a given point in normalized screen coordinates (see projectToScreen()) onto...
void projectPointToLine(const SbVec2f &pt, SbVec3f &line0, SbVec3f &line1) const
~SbViewVolume()
Constructor and destructor.
void scaleWidth(float ratio)
Scales view volume to be the given ratio of its current width, leaving the resulting view volume cent...
SbPlane getPlane(float distFromEye) const
Returns a plane parallel to the near (or far) plane of the view volume at a given distance from the p...
bool intersect(const SbVec3f &point) const
Returns TRUE if view volume contains point.
SbLine projectPointToLine(const SbVec2f &pt) const
Maps a 2d point (in 0 <= x,y <= 1) to a 3d line.
void perspective(float fovy, float aspect, float nearVal, float farVal)
Sets up a perspective view volume with the given field of view and aspect ratio.
float getWidth() const
Returns bounds of viewing frustum.
SbVec3f projPoint
Note that there is redundant info in this data structure and its elements should not be changed by ha...
const SbVec3f & getProjectionDirection() const
Returns projection information.
SbMatrix getMatrix() const
Like the method above, but returns the affine and projection parts together in one matrix (i....
float getFarDist() const
Returns distance from projection point to far plane.
SbVec3f getSightPoint(float distFromEye) const
Returns the point along the line of sight at the given distance from the projection point (eye).
bool intersect(const SbBox3f &box) const
Returns TRUE if bounding box may intersect volume.
SbVec2f projectBox(const SbBox3f &box) const
Projects the given 3D bounding box onto the near plane and returns the size (in normalized screen coo...
SbMatrix getCameraSpaceMatrix() const
Returns a matrix that transforms the view volume into camera space: it translates the view volume so ...
SbMatrix getViewingMatrix() const
Returns the affine viewing matrix.
SbVec3f zVector() const
Returns the positive z axis in eye space.
SbViewVolume zNarrow(float nearVal, float farVal) const
Returns a narrowed view volume which contains as tightly as possible the given interval on the z axis...
float getNearDist() const
Returns distance from projection point to near plane.
bool outsideTest(const SbPlane &p, const SbVec3f &min, const SbVec3f &max) const
Returns TRUE if the bounding box defined by min,max is totally outside plane p.