![]() |
http://www.sim.no http://www.coin3d.org |
The SbVec3f class is a 3 dimensional vector with floating point coordinates. More...
#include <Inventor/SbLinear.h>
Public Member Functions | |
SbVec3f (void) | |
SbVec3f (const float v[3]) | |
SbVec3f (const float x, const float y, const float z) | |
SbVec3f (const SbPlane &p0, const SbPlane &p1, const SbPlane &p2) | |
SbVec3f (const SbVec3d &v) | |
SbVec3f (const SbVec3b &v) | |
SbVec3f (const SbVec3s &v) | |
SbVec3f (const SbVec3i32 &v) | |
SbVec3f & | setValue (const float v[3]) |
SbVec3f & | setValue (const float x, const float y, const float z) |
SbVec3f & | setValue (const SbVec3f &barycentric, const SbVec3f &v0, const SbVec3f &v1, const SbVec3f &v2) |
SbVec3f & | setValue (const SbVec3d &v) |
SbVec3f & | setValue (const SbVec3b &v) |
SbVec3f & | setValue (const SbVec3s &v) |
SbVec3f & | setValue (const SbVec3i32 &v) |
SbVec3f | cross (const SbVec3f &v) const |
float | dot (const SbVec3f &v) const |
SbBool | equals (const SbVec3f &v, const float tolerance) const |
SbVec3f | getClosestAxis (void) const |
const float * | getValue (void) const |
void | getValue (float &x, float &y, float &z) const |
float | length (void) const |
float | sqrLength () const |
void | negate (void) |
float | normalize (void) |
float & | operator[] (const int i) |
const float & | operator[] (const int i) const |
SbVec3f & | operator*= (const float d) |
SbVec3f & | operator/= (const float d) |
SbVec3f & | operator+= (const SbVec3f &u) |
SbVec3f & | operator-= (const SbVec3f &u) |
SbVec3f | operator- (void) const |
void | print (FILE *fp) const |
Friends | |
SbVec3f | operator* (const SbVec3f &v, const float d) |
SbVec3f | operator* (const float d, const SbVec3f &v) |
SbVec3f | operator/ (const SbVec3f &v, const float d) |
SbVec3f | operator+ (const SbVec3f &v1, const SbVec3f &v2) |
SbVec3f | operator- (const SbVec3f &v1, const SbVec3f &v2) |
int | operator== (const SbVec3f &v1, const SbVec3f &v2) |
int | operator!= (const SbVec3f &v1, const SbVec3f &v2) |
The SbVec3f class is a 3 dimensional vector with floating point coordinates.
This vector class is used by many other classes in Coin. It provides storage for a 3 dimensional vector aswell as simple floating point arithmetic operations.
|
inline |
The default constructor does nothing. The vector coordinates will be uninitialized until you do a setValue() call.
Referenced by cross(), and operator-().
SbVec3f::SbVec3f | ( | const float | v[3] | ) |
Constructs an SbVec3f instance with initial values from v.
SbVec3f::SbVec3f | ( | const float | x, |
const float | y, | ||
const float | z | ||
) |
Constructs an SbVec3f instance with the initial vector endpoint set to <x,y,z>.
Constructs an SbVec3f instance by combining the three given planes. None of the planes should be parallel to any of the other two, otherwise a divide by zero error will occur.
References dot(), SbPlane::getDistanceFromOrigin(), SbPlane::getNormal(), and SoDebugError::postWarning().
SbVec3f::SbVec3f | ( | const SbVec3d & | v | ) |
Constructs an SbVec3f instance with initial values from the double precision vector v.
This is a Coin extension.
DEPRECATED
for Coin 3.0 – don't use this.
References setValue().
|
inlineexplicit |
Constructs an SbVec3d instance with initial values from the 8-bit integer precision vector v.
|
inlineexplicit |
Constructs an SbVec3f instance with initial values from the short integer precision vector v.
|
inlineexplicit |
Constructs an SbVec3d instance with initial values from the 32-bit integer precision vector v.
SbVec3f & SbVec3f::setValue | ( | const float | v[3] | ) |
Set new coordinates for the vector from v. Returns reference to self.
Referenced by SoVRMLBox::computeBBox(), SoSphere::computeBBox(), SoVRMLSphere::computeBBox(), SoIndexedShape::computeBBox(), SoVRMLCone::computeBBox(), SoCube::computeBBox(), SoVRMLCylinder::computeBBox(), SoIndexedNurbsCurve::computeBBox(), SoCone::computeBBox(), SoCylinder::computeBBox(), SoNonIndexedShape::computeCoordBBox(), SoTrackballDragger::dragStart(), SoTabPlaneDragger::dragStart(), SbXfBox3f::extendBy(), SbBox3f::extendBy(), SoGetBoundingBoxAction::getCenter(), SoShape::getScreenSize(), SbBox3f::getSpan(), SbBox3i32::getSpan(), SbRotation::getValue(), SoRayPickAction::intersect(), SbBox3f::makeEmpty(), SoCamera::pointAt(), SoTabPlaneDragger::reallyAdjustScaleTabSize(), SoGetBoundingBoxAction::resetCenter(), SbVec3f(), SoVRMLInline::setBoundingBoxColor(), SbBox3f::setBounds(), SbColor::setHSVValue(), SbColor::setPackedValue(), SoPrimitiveVertex::setPoint(), SbSphereSheetProjector::setupPlane(), SbSphereSectionProjector::setupTolerance(), SoSFColor::setValue(), SoMotion3Event::SoMotion3Event(), SbBox3f::transform(), SbBox3i32::transform(), and SoSurroundScale::updateMySurroundParams().
SbVec3f & SbVec3f::setValue | ( | const float | x, |
const float | y, | ||
const float | z | ||
) |
Set new coordinates for the vector. Returns reference to self.
SbVec3f & SbVec3f::setValue | ( | const SbVec3f & | barycentric, |
const SbVec3f & | v0, | ||
const SbVec3f & | v1, | ||
const SbVec3f & | v2 | ||
) |
Set this vector to be the average of v0, v1 and v2. The vector components are weighted by the barycentric vector.
Sets this vector to the double precision vector v, converting the vector to a single precision vector.
This is a Coin extension.
References SoDebugError::postWarning().
Set new coordinates for the vector from v. Returns reference to self.
Set new coordinates for the vector from v. Returns reference to self.
Set new coordinates for the vector from v. Returns reference to self.
SbVec3f::SbVec3f(const SbVec3b & v)
Constructs an SbVec3f instance with initial values from the vector v.
SbVec3f::SbVec3f(const SbVec3s & v)
Constructs an SbVec3f instance with initial values from the vector v.
SbVec3f::SbVec3f(const SbVec3i32 & v)
Constructs an SbVec3f instance with initial values from the vector v.
Returns the result of taking the cross product of this vector and v.
References SbVec3f().
Referenced by SoRotateDiscDragger::drag(), SbSpherePlaneProjector::getRotation(), SbCylinderPlaneProjector::getRotation(), SoCamera::GLRender(), SbCylinder::intersect(), SbPlane::intersect(), and SbRotation::setValue().
float SbVec3f::dot | ( | const SbVec3f & | v | ) | const |
Calculates and returns the result of taking the dot product of this vector and v.
Referenced by SbClip::clip(), SoRotateDiscDragger::drag(), SoScale2UniformDragger::drag(), SoScaleUniformDragger::drag(), SoSpotLightDragger::drag(), SoTrackballDragger::drag(), SoTabPlaneDragger::drag(), SbPlane::getDistance(), SbCylinderSheetProjector::getRotation(), SbCylinderSectionProjector::getRotation(), SbCylinderPlaneProjector::getRotation(), SbSpherePlaneProjector::getRotation(), SbBox3f::getSpan(), SbBox3i32::getSpan(), SbCylinder::intersect(), SbPlane::intersect(), SbSphere::intersect(), SbCylinderProjector::isPointInFront(), SbSphereProjector::isPointInFront(), SoCamera::pointAt(), SbPlane::SbPlane(), SbVec3f(), SbRotation::setValue(), SbPlane::transform(), and SoFrustumCamera::viewBoundingBox().
SbBool SbVec3f::equals | ( | const SbVec3f & | v, |
const float | tolerance | ||
) | const |
Compares the vector with v and returns TRUE
if the distance between the vectors is smaller or equal to the square root of tolerance.
References SoDebugError::postWarning().
SbVec3f SbVec3f::getClosestAxis | ( | void | ) | const |
Return the vector representing the principal axis closest to this vector.
const float * SbVec3f::getValue | ( | void | ) | const |
Returns a pointer to an array of three floats containing the x, y and z coordinates of the vector.
Referenced by SoListener::audioRender(), SoVRMLSound::audioRender(), SoCamera::audioRender(), SbBox3f::getBounds(), SbBox3f::getOrigin(), SoSpotLight::GLRender(), SoVRMLSpotLight::GLRender(), SoVRMLElevationGrid::GLRender(), SoWWWInline::GLRender(), SoShape::invokeLineSegmentCallbacks(), SoShape::invokePointCallbacks(), SoShape::invokeTriangleCallbacks(), SoCamera::jitter(), and SoTransformManip::valueChangedCB().
void SbVec3f::getValue | ( | float & | x, |
float & | y, | ||
float & | z | ||
) | const |
Returns the x, y and z coordinates of the vector.
float SbVec3f::length | ( | void | ) | const |
Return length of vector.
Referenced by SoVRMLSound::audioRender(), SoScale2UniformDragger::drag(), SoScaleUniformDragger::drag(), SoSpotLightDragger::drag(), SoTrackballDragger::drag(), SoTabPlaneDragger::drag(), SoVRMLSphereSensor::dragStart(), SoRotateSphericalDragger::dragStart(), SoTrackballDragger::dragStart(), SoTransformerDragger::dragStart(), SbBSPTree::findClosest(), SbLine::getClosestPoint(), SbLine::getClosestPoints(), SbSpherePlaneProjector::getRotation(), SbCylinder::intersect(), SbSphere::intersect(), normalize(), SbRotation::SbRotation(), SbCylinder::setAxis(), and SbRotation::setValue().
float SbVec3f::sqrLength | ( | void | ) | const |
Returns the squared length of the vector.
Referenced by SbPlane::intersect(), and SbPlane::SbPlane().
void SbVec3f::negate | ( | void | ) |
Negate the vector (i.e. point it in the opposite direction).
Referenced by SbSphereSheetProjector::project().
float SbVec3f::normalize | ( | void | ) |
Normalize the vector to unit length. Return value is the original length of the vector before normalization.
If the vector is the null vector, no attempt at normalization will be done. If the Coin library was built in a debug version, and the COIN_DEBUG_NORMALIZE environment variable is set, this error message will then be shown:
Coin warning in SbVec3f::normalize(): The length of the vector should be > 0.0f to be able to normalize.
We've made it possible for Coin to spit out a warning when an attempt at normalizing a null-vector is made, as that seems to sometimes be a symptom caused by some graver error somewhere else – either an internal error in Coin code, a programming error in application code, or an error in an input file (like for instance invalid polygon specifications).
If you run into bugs/problems with your application or with Coin, it could be a good idea to set COIN_DEBUG_NORMALIZE=1, and then restart the application to see if you get any warnings from normalize().
If this happens, you should run the application in a debugger and see how the call-stack backtrace looks when it hits. An easy way of getting a debugger break at the warning spot is to set the following debugging environment variable which will make the code assert:
COIN_DEBUG_BREAK="SbVec3f::normalize"
If you from the backtrace analysis strongly suspects an internal Coin bug, please report the call-stack to us at coin- and we'll look into it. Example code that triggers the bug would then also be very helpful. supp ort@c oin3 d.org
A note for developers porting code from SGI or TGS Inventor to Coin: those Inventor implementations are more slack about detecting and giving out warning messages upon API misuses, and you may suddenly have gotten this warning with Coin without seeing any indication of an error with SGI/TGS Inventor. This does not necessarily mean that it is a bug in Coin – it is much more likely that you are getting a warning as an indication of API misuse or import file errors which were just not detected and/or reported with those Inventor implementations.
References length(), operator/=(), and SoDebugError::postWarning().
Referenced by SoVRMLSound::audioRender(), SbClip::clip(), SoRotateDiscDragger::drag(), SoTrackballDragger::drag(), SoTrackballDragger::dragStart(), SoImage::generatePrimitives(), SbLine::getClosestPoints(), SbSpherePlaneProjector::getRotation(), SbBox3f::getSpan(), SbBox3i32::getSpan(), SoVRMLDirectionalLight::GLRender(), SoCamera::GLRender(), SbCylinder::intersect(), SbSphere::intersect(), SoShape::invokeLineSegmentCallbacks(), SoShape::invokeTriangleCallbacks(), SoVRMLTransform::pointAt(), SoTransform::pointAt(), SoCamera::pointAt(), SbPlane::SbPlane(), SbSphereSheetProjector::setupPlane(), SbCylinderSheetProjector::setupPlane(), SbCylinderSectionProjector::setupTolerance(), SbSphereSectionProjector::setupTolerance(), SbLine::setValue(), SbRotation::setValue(), SbPlane::transform(), SoOrthographicCamera::viewBoundingBox(), SoPerspectiveCamera::viewBoundingBox(), and SoFrustumCamera::viewBoundingBox().
|
inline |
Index operator. Returns modifiable x, y or z coordinate of vector.
|
inline |
Index operator. Returns x, y or z coordinate of vector.
SbVec3f & SbVec3f::operator*= | ( | const float | d | ) |
Multiply components of vector with scalar value d. Returns reference to self.
SbVec3f & SbVec3f::operator/= | ( | const float | d | ) |
Divides components of vector with scalar value d. Returns reference to self.
References SoDebugError::postWarning().
Referenced by normalize().
Adds this vector and vector u. Returns reference to self.
Subtracts vector u from this vector. Returns reference to self.
SbVec3f SbVec3f::operator- | ( | void | ) | const |
void SbVec3f::print | ( | FILE * | fp | ) | const |
Dump the state of this object to the file stream. Only works in debug version of library, method does nothing in an optimized compile.
Referenced by SbLine::print(), SbSphere::print(), SbPlane::print(), SbXfBox3f::print(), SbBox3f::print(), and SbViewVolume::print().
Returns an SbVec3f instance which is the components of vector v multiplied with d.
Returns an SbVec3f instance which is the components of vector v multiplied with d.
Returns an SbVec3f instance which is the components of vector v divided on the scalar factor d.
Returns an SbVec3f instance which is the sum of vectors v1 and v2.
Returns an SbVec3f instance which is vector v2 subtracted from vector v1.
Returns 1 if v1 and v2 are exactly equal, 0 otherwise.
Returns 1 if v1 and v2 are not equal, 0 if they are equal.
Copyright © 1998-2007 by Systems in Motion AS. All rights reserved.
Generated on Fri Jul 20 2018 for Coin by Doxygen. 1.8.14