This documentation is automatically generated from the openFrameworks source code using doxygen and refers to the most recent release, version 0.12.0.
ofVec3f is a class for storing a three dimensional vector. More...
#include <ofVec3f.h>
Public Member Functions | |
Construct a 3D vector | |
ofVec3f () | |
Construct a 3D vector. Defaults to (0,0,0). | |
ofVec3f (float x, float y, float z=0) | |
Construt a 3D vector with x , y and z specified. | |
ofVec3f (float scalar) | |
Construct a 3D vector with x , y and z set to scalar | |
ofVec3f (const ofVec2f &vec) | |
ofVec3f (const ofVec4f &vec) | |
Construct a new 3D vector from a 4D vector by throwing away the 'w' component. | |
ofVec3f (const glm::vec2 &vec) | |
ofVec3f (const glm::vec3 &vec) | |
ofVec3f (const glm::vec4 &vec) | |
operator glm::vec3 () const | |
Access components | |
float * | getPtr () |
Returns a pointer to the memory position of the first element of the vector ('x'); the other elements ('y' and 'z') immediately follow it in memory. | |
const float * | getPtr () const |
float & | operator[] (int n) |
Allows to access the individual components of an 'ofVec3f' as though it is an array. | |
float | operator[] (int n) const |
void | set (float x, float y, float z=0) |
Set 'x', 'y' and 'z' components of this vector with just one function call. 'z' is optional, it defaults to 0. | |
void | set (const ofVec3f &vec) |
Setting the values by using other 3 dimension vector ofVec3f. | |
void | set (float _scalar) |
Comparison | |
bool | operator== (const ofVec3f &vec) const |
Check for equality between two ofVec3f. | |
bool | operator!= (const ofVec3f &vec) const |
Returns 'true' if any component is different to its corresponding component in 'vec', ie if 'x != vec.x' or 'y != vec.y' or 'z != vec.z'; otherwise returns 'false'. | |
bool | match (const ofVec3f &vec, float tolerance=0.0001f) const |
Let you check if two vectors are similar given a tolerance threshold 'tolerance' (default = 0.0001). | |
bool | isAligned (const ofVec3f &vec, float tolerance=0.0001f) const |
bool | isAlignedRad (const ofVec3f &vec, float tolerance=0.0001f) const |
bool | align (const ofVec3f &vec, float tolerance=0.0001f) const |
Returns 'true' if this vector is pointing in the same direction as 'vec', with an angle error threshold 'tolerance' in degrees (default 0.0001 degrees). | |
bool | alignRad (const ofVec3f &vec, float tolerance=0.0001f) const |
Returns 'true' if this vector is pointing in the same direction as 'vec', with an angle error threshold 'tolerance' in radians (default 0.0001). | |
Operators | |
ofVec3f | operator+ (const ofVec3f &pnt) const |
ofVec3f | operator+ (const float f) const |
ofVec3f & | operator+= (const ofVec3f &pnt) |
ofVec3f & | operator+= (const float f) |
ofVec3f | operator- (const ofVec3f &vec) const |
ofVec3f | operator- (const float f) const |
ofVec3f | operator- () const |
ofVec3f & | operator-= (const ofVec3f &vec) |
ofVec3f & | operator-= (const float f) |
ofVec3f | operator* (const ofVec3f &vec) const |
ofVec3f | operator* (const float f) const |
ofVec3f & | operator*= (const ofVec3f &vec) |
ofVec3f & | operator*= (const float f) |
ofVec3f | operator/ (const ofVec3f &vec) const |
ofVec3f | operator/ (const float f) const |
ofVec3f & | operator/= (const ofVec3f &vec) |
ofVec3f & | operator/= (const float f) |
Simple manipulations | |
ofVec3f | getScaled (const float length) const |
Return a new 'ofVec3f' that is the result of scaling this vector up or down so that it has the requested length. | |
ofVec3f & | scale (const float length) |
Scales this vector up or down so that it has the requested length. | |
ofVec3f | getRotated (float angle, const ofVec3f &axis) const |
Returns a new vector that is the result of rotating this vector by 'angle' degrees about the given axis. | |
ofVec3f | getRotated (float ax, float ay, float az) const |
Returns a new vector that is the result of performing an Euler rotation of this vector by 'ax' degrees about the x axis, 'ay' degrees about the y axis, and 'az' degrees about the z axis. | |
ofVec3f | getRotated (float angle, const ofVec3f &pivot, const ofVec3f &axis) const |
Returns a new vector that is the result of rotating this vector by 'angle' degrees about the axis specified by 'axis', using 'pivot' as the origin of rotation. | |
ofVec3f | getRotatedRad (float angle, const ofVec3f &axis) const |
Returns a new vector that is the result of rotating this vector by 'angle' radians about the given axis. | |
ofVec3f | getRotatedRad (float ax, float ay, float az) const |
Returns a new vector that is the result of performing an Euler rotation of this vector by 'ax' radians about the x axis, 'ay' radians about the y axis, and 'az' radians about the z axis. | |
ofVec3f | getRotatedRad (float angle, const ofVec3f &pivot, const ofVec3f &axis) const |
Returns a new vector that is the result of rotating this vector by 'angle' radians about the axis specified by 'axis', using 'pivot' as the origin of rotation. | |
ofVec3f & | rotate (float angle, const ofVec3f &axis) |
Rotates this vector by 'angle' degrees around the given axis. | |
ofVec3f & | rotate (float ax, float ay, float az) |
Performs an Euler rotation of this vector by 'ax' degrees about the x axis, 'ay' degrees about the y axis, and 'az' degrees about the z axis. | |
ofVec3f & | rotate (float angle, const ofVec3f &pivot, const ofVec3f &axis) |
Rotates this vector by 'angle' degrees about the axis specified by 'axis', using 'pivot' as the origin of rotation. | |
ofVec3f & | rotateRad (float angle, const ofVec3f &axis) |
Rotates this vector by 'angle' radians about the given axis. | |
ofVec3f & | rotateRad (float ax, float ay, float az) |
Performs an Euler rotation of this vector by 'ax' radians about the x axis, 'ay' radians about the y axis, and 'az' radians about the z axis. | |
ofVec3f & | rotateRad (float angle, const ofVec3f &pivot, const ofVec3f &axis) |
Rotates this vector by 'angle' radians around the axis specified by 'axis', using 'pivot' as the origin of rotation. | |
ofVec3f | getMapped (const ofVec3f &origin, const ofVec3f &vx, const ofVec3f &vy, const ofVec3f &vz) const |
Return a new 'ofVec3f' calculated by copying this vector and then mapping from its default coordinate system – origin (0,0,0), X direction (1,0,0), Y direction (0,1,0), Z direction (0,0,1) – to a new coordinate system defined with origin at 'origin', X direction 'vx', and Y direction 'vy', and Z direction 'vz'. | |
ofVec3f & | map (const ofVec3f &origin, const ofVec3f &vx, const ofVec3f &vy, const ofVec3f &vz) |
Map this vector from its default coordinate system – origin (0,0,0), X direction (1,0,0), Y direction (0,1,0), Z direction (0,0,1) – to a new coordinate system defined with origin at 'origin', X direction 'vx', and Y direction 'vy', and Z direction 'vz'. | |
Distance | |
float | distance (const ofVec3f &pnt) const |
Treats both this vector and 'pnt' as points in 3D space, and calculates and returns the distance between them. | |
float | squareDistance (const ofVec3f &pnt) const |
Treats both this vector and 'pnt' as points in 3D space, and calculates and returns the squared distance between them. | |
Interpolation | |
ofVec3f | getInterpolated (const ofVec3f &pnt, float p) const |
Perform a linear interpolation of this vector's position towards 'pnt' and return the interpolated vector without altering the original. 'p' controls the amount to move towards 'pnt'. 'p' is normally between 0 and 1 and where 0 means stay the original position and 1 means move all the way to 'pnt', but you can also have 'p' greater than 1 overshoot 'pnt', or less than 0 to move backwards away from 'pnt'. | |
ofVec3f & | interpolate (const ofVec3f &pnt, float p) |
Perform a linear interpolation of this vector's position towards 'pnt'. 'p' controls the amount to move towards 'pnt'. 'p' is normally between 0 and 1 and where 0 means stay the original position and 1 means move all the way to 'pnt', but you can also have 'p' greater than 1 overshoot 'pnt', or less than 0 to move backwards away from 'pnt'. | |
ofVec3f | getMiddle (const ofVec3f &pnt) const |
Calculate and return the midpoint between this vector and 'pnt'. | |
ofVec3f & | middle (const ofVec3f &pnt) |
ofVec3f & | average (const ofVec3f *points, int num) |
Sets this vector to be the average (centre of gravity or centroid) of a given array of 'ofVec3f's. 'points' is the array of 'ofVec3f's and 'num' specifies the number of 'ofVec3f's in the array. | |
Limit | |
ofVec3f | getNormalized () const |
Return a normalized copy of this vector. | |
ofVec3f & | normalize () |
Normalize the vector. | |
ofVec3f | getLimited (float max) const |
Return a copy of this vector with its length (magnitude) restricted to a maximum of 'max' units by scaling down if necessary. | |
ofVec3f & | limit (float max) |
Restrict the length (magnitude) of this vector to a maximum of 'max' units by scaling down if necessary. | |
Measurement | |
float | length () const |
float | lengthSquared () const |
Return the squared length (squared magnitude) of this vector. | |
float | angle (const ofVec3f &vec) const |
Calculate and return the coplanar angle in degrees between this vector and 'vec'. | |
float | angleRad (const ofVec3f &vec) const |
Calculate and return the coplanar angle in radians between this vector and 'vec'. | |
Perpendicular | |
ofVec3f | getPerpendicular (const ofVec3f &vec) const |
Construct a plane using this vector and 'vec' (by finding the plane that both lectors lie on), and return the vector that is perpendicular to that plane (the normal to that plane). | |
ofVec3f & | perpendicular (const ofVec3f &vec) |
Construct a plane using this vector and 'vec' (by finding the plane that both lie on), and set our 'x', 'y' and 'z' to be the vector that is perpendicular to the constructed plane (the normal to the plane). | |
ofVec3f | getCrossed (const ofVec3f &vec) const |
Returns the cross product (vector product) of this vector and 'vec'. This is a binary operation on two vectors in three-dimensional space, which results in a vector that is perpendicular to both of the vectors being multiplied, and normal to the plane containing them. The name cross product is derived from the cross symbol X that is often used to designate this operation; the alternative name vector product emphasizes the vector (rather than scalar) nature of the result. | |
ofVec3f & | cross (const ofVec3f &vec) |
float | dot (const ofVec3f &vec) const |
Returns the dot product of this vector with 'vec'. | |
Public Attributes | |
float | x |
Stores the X component of this vector. | |
float | y |
Stores the Y component of this vector. | |
float | z |
Stores the Z component of this vector. | |
Detailed Description
ofVec3f is a class for storing a three dimensional vector.
Moving through space requires knowledge of where things are and where they are going. Vector Maths is the class of mathematics that gives us control over these things in space, allowing for elegant and intuitive descriptions of complex structures and movement. Vectors are at the heart of animations, particle systems, and 2D and 3D graphics.
Vectors in mathematics in general are entities with magnitude (also called length) and direction. A vector whose magnitude is 1 (ie a vector that is normalized) is called a unit vector. Unit vectors are very handy for storing directions as they can be easily scaled up (or down) to represent motion in a particular direction with a particular length.
You will also see the term 'vector' used to describe an array of objects in C++ (such as text strings). Don't let this confuse you, they are quite different: one of them is a mathematical term for a fixed-length list of numbers that you can do mathematical operations on, the other is a C++-specific term that means 'dynamically sizeable array'.
'ofVec3f has three member variables, x, y, and z, which allow to conveniently 'store 3D properties of an object such as its position, velocity, or 'acceleration.
Using 'ofVec3f' greatly simplifies arithmetic operations in three dimensions. For example if you have two vectors 'v1' and 'v2', both of which represent a 3D change in position, you can find the total change of position of both of them just by doing an addition 'v1 + v2':
You can scale an 'ofVec3f' by multiplying it with a float:
This also works for subtraction and division.
As you can see this really makes dealing with vectors as easy as dealing with single 'float's or 'int's, and can reduce the number of lines of code you have to write by half, at the same time making your code much easier to read and understand!
Constructor & Destructor Documentation
◆ ofVec3f() [1/8]
ofVec3f::ofVec3f | ( | ) |
◆ ofVec3f() [2/8]
ofVec3f::ofVec3f | ( | float | x, |
float | y, | ||
float | z = 0 |
||
) |
Construt a 3D vector with x
, y
and z
specified.
◆ ofVec3f() [3/8]
|
explicit |
Construct a 3D vector with x
, y
and z
set to scalar
◆ ofVec3f() [4/8]
ofVec3f::ofVec3f | ( | const ofVec2f & | vec | ) |
◆ ofVec3f() [5/8]
ofVec3f::ofVec3f | ( | const ofVec4f & | vec | ) |
◆ ofVec3f() [6/8]
ofVec3f::ofVec3f | ( | const glm::vec2 & | vec | ) |
◆ ofVec3f() [7/8]
ofVec3f::ofVec3f | ( | const glm::vec3 & | vec | ) |
◆ ofVec3f() [8/8]
ofVec3f::ofVec3f | ( | const glm::vec4 & | vec | ) |
Member Function Documentation
◆ align()
bool ofVec3f::align | ( | const ofVec3f & | vec, |
float | tolerance = 0.0001f |
||
) | const |
◆ alignRad()
bool ofVec3f::alignRad | ( | const ofVec3f & | vec, |
float | tolerance = 0.0001f |
||
) | const |
◆ angle()
float ofVec3f::angle | ( | const ofVec3f & | vec | ) | const |
◆ angleRad()
float ofVec3f::angleRad | ( | const ofVec3f & | vec | ) | const |
◆ average()
Sets this vector to be the average (centre of gravity or centroid) of a given array of 'ofVec3f's. 'points' is the array of 'ofVec3f's and 'num' specifies the number of 'ofVec3f's in the array.
◆ cross()
Set this vector to the cross product (vector product) of itself and 'vec'. This is a binary operation on two vectors in three-dimensional space, which results in a vector that is perpendicular to both of the vectors being multiplied, and normal to the plane containing them. The name cross product is derived from the cross symbol X that is often used to designate this operation; the alternative name vector product emphasizes the vector (rather than scalar) nature of the result.
◆ distance()
float ofVec3f::distance | ( | const ofVec3f & | pnt | ) | const |
Treats both this vector and 'pnt' as points in 3D space, and calculates and returns the distance between them.
'distance' involves a square root calculation, which is one of the slowest things you can do in programming. If you don't need an exact number but rather just a rough idea of distance (for example when finding the shortest distance of a bunch of points to a reference point, where it doesn't matter exactly what the distances are, you just want the shortest), you can use squareDistance() instead.
◆ dot()
float ofVec3f::dot | ( | const ofVec3f & | vec | ) | const |
Returns the dot product of this vector with 'vec'.
The dot product of two vectors, also known as the scalar product, is the product of the magnitude of the two vectors and the cosine of the angle between them.
One interpretation of the dot product is as a measure of how closely two vectors align with each other. If they point in exactly the same direction, their dot product will simply be the product of their magnitudes, if they are perpendicular, their dot product will be 0, and if they point in opposite directions, their dot product will be negative.
The dot product is in contrast to the cross product, which returns a vector rather than a scalar.
◆ getCrossed()
Returns the cross product (vector product) of this vector and 'vec'. This is a binary operation on two vectors in three-dimensional space, which results in a vector that is perpendicular to both of the vectors being multiplied, and normal to the plane containing them. The name cross product is derived from the cross symbol X that is often used to designate this operation; the alternative name vector product emphasizes the vector (rather than scalar) nature of the result.
Image courtesy of Wikipedia
◆ getInterpolated()
Perform a linear interpolation of this vector's position towards 'pnt' and return the interpolated vector without altering the original. 'p' controls the amount to move towards 'pnt'. 'p' is normally between 0 and 1 and where 0 means stay the original position and 1 means move all the way to 'pnt', but you can also have 'p' greater than 1 overshoot 'pnt', or less than 0 to move backwards away from 'pnt'.
◆ getLimited()
ofVec3f ofVec3f::getLimited | ( | float | max | ) | const |
Return a copy of this vector with its length (magnitude) restricted to a maximum of 'max' units by scaling down if necessary.
◆ getMapped()
ofVec3f ofVec3f::getMapped | ( | const ofVec3f & | origin, |
const ofVec3f & | vx, | ||
const ofVec3f & | vy, | ||
const ofVec3f & | vz | ||
) | const |
Return a new 'ofVec3f' calculated by copying this vector and then mapping from its default coordinate system – origin (0,0,0), X direction (1,0,0), Y direction (0,1,0), Z direction (0,0,1) – to a new coordinate system defined with origin at 'origin', X direction 'vx', and Y direction 'vy', and Z direction 'vz'.
In most cases you want 'vx', 'vy', and 'vz' to be perpendicular and of unit length; if they are not perpendicular you will have shearing as part of the mapping, and if they are not of unit length you will have scaling as part of the mapping.
◆ getMiddle()
◆ getNormalized()
ofVec3f ofVec3f::getNormalized | ( | ) | const |
Return a normalized copy of this vector.
Normalization means to scale the vector so that its length (magnitude) is exactly 1, at which stage all that is left is the direction. A normalized vector is usually called a unit vector, and can be used to represent a pure direction (heading).
◆ getPerpendicular()
Construct a plane using this vector and 'vec' (by finding the plane that both lectors lie on), and return the vector that is perpendicular to that plane (the normal to that plane).
This method is usually used to calculate a normal vector to a surface, which can then be used to calculate lighting, collisions, and other 3D effects.
◆ getPtr() [1/2]
|
inline |
Returns a pointer to the memory position of the first element of the vector ('x'); the other elements ('y' and 'z') immediately follow it in memory.
This is very useful when using arrays of 'ofVec3f's to store geometry information, as it allows the vector to be treated as a simple C array of 'float's that can be passed verbatim to OpenGL.
◆ getPtr() [2/2]
|
inline |
◆ getRotated() [1/3]
Returns a new vector that is the result of rotating this vector by 'angle' degrees about the given axis.
◆ getRotated() [2/3]
Returns a new vector that is the result of rotating this vector by 'angle' degrees about the axis specified by 'axis', using 'pivot' as the origin of rotation.
◆ getRotated() [3/3]
ofVec3f ofVec3f::getRotated | ( | float | ax, |
float | ay, | ||
float | az | ||
) | const |
Returns a new vector that is the result of performing an Euler rotation of this vector by 'ax' degrees about the x axis, 'ay' degrees about the y axis, and 'az' degrees about the z axis.
Watch out for gimbal lock when specifying multiple rotations in the same call.
◆ getRotatedRad() [1/3]
Returns a new vector that is the result of rotating this vector by 'angle' radians about the given axis.
◆ getRotatedRad() [2/3]
Returns a new vector that is the result of rotating this vector by 'angle' radians about the axis specified by 'axis', using 'pivot' as the origin of rotation.
◆ getRotatedRad() [3/3]
ofVec3f ofVec3f::getRotatedRad | ( | float | ax, |
float | ay, | ||
float | az | ||
) | const |
Returns a new vector that is the result of performing an Euler rotation of this vector by 'ax' radians about the x axis, 'ay' radians about the y axis, and 'az' radians about the z axis.
Watch out for gimbal lock when specifying multiple rotations in the same call.
◆ getScaled()
ofVec3f ofVec3f::getScaled | ( | const float | length | ) | const |
◆ interpolate()
Perform a linear interpolation of this vector's position towards 'pnt'. 'p' controls the amount to move towards 'pnt'. 'p' is normally between 0 and 1 and where 0 means stay the original position and 1 means move all the way to 'pnt', but you can also have 'p' greater than 1 overshoot 'pnt', or less than 0 to move backwards away from 'pnt'.
◆ isAligned()
bool ofVec3f::isAligned | ( | const ofVec3f & | vec, |
float | tolerance = 0.0001f |
||
) | const |
Checks if vectors look in the same direction.
◆ isAlignedRad()
bool ofVec3f::isAlignedRad | ( | const ofVec3f & | vec, |
float | tolerance = 0.0001f |
||
) | const |
◆ length()
float ofVec3f::length | ( | ) | const |
Return the length (magnitude) of this vector.
‘length’ involves a square root calculation, which is one of the slowest things you can do in programming. If you don't need an exact number but rather just a rough idea of a length (for example when finding the shortest distance of a bunch of points to a reference point, where it doesn't matter exactly what the lengths are, you just want the shortest), you can use lengthSquared() instead.
◆ lengthSquared()
float ofVec3f::lengthSquared | ( | ) | const |
Return the squared length (squared magnitude) of this vector.
Use as a much faster alternative to length() if you don't need to know an accurate length but rather just a rough idea of a length (for example when finding the shortest distance of a bunch of points to a reference point, where it doesn't matter exactly what the lengths are, you just want the shortest). It avoids the square root calculation that is ordinarily required to calculate a length.
◆ limit()
ofVec3f & ofVec3f::limit | ( | float | max | ) |
Restrict the length (magnitude) of this vector to a maximum of 'max' units by scaling down if necessary.
◆ map()
ofVec3f & ofVec3f::map | ( | const ofVec3f & | origin, |
const ofVec3f & | vx, | ||
const ofVec3f & | vy, | ||
const ofVec3f & | vz | ||
) |
Map this vector from its default coordinate system – origin (0,0,0), X direction (1,0,0), Y direction (0,1,0), Z direction (0,0,1) – to a new coordinate system defined with origin at 'origin', X direction 'vx', and Y direction 'vy', and Z direction 'vz'.
In most cases you want 'vx', 'vy', and 'vz' to be perpendicular and of unit length; if they are not perpendicular you will have shearing as part of the mapping, and if they are not of unit length you will have scaling as part of the mapping.
◆ match()
bool ofVec3f::match | ( | const ofVec3f & | vec, |
float | tolerance = 0.0001f |
||
) | const |
◆ middle()
Set this vector to the midpoint between itself and 'pnt'.
◆ normalize()
ofVec3f & ofVec3f::normalize | ( | ) |
Normalize the vector.
Normalizing means to scale the vector so that its length (magnitude) is exactly 1, at which stage all that is left is the direction. A normalized vector is usually called a unit vector, and can be used to represent a pure direction (heading).
◆ operator glm::vec3()
ofVec3f::operator glm::vec3 | ( | ) | const |
◆ operator!=()
bool ofVec3f::operator!= | ( | const ofVec3f & | vec | ) | const |
◆ operator*() [1/2]
ofVec3f ofVec3f::operator* | ( | const float | f | ) | const |
◆ operator*() [2/2]
◆ operator*=() [1/2]
ofVec3f & ofVec3f::operator*= | ( | const float | f | ) |
Scale this vector by multiplying 'x', 'y' and 'z' members by 'f'.
◆ operator*=() [2/2]
◆ operator+() [1/2]
ofVec3f ofVec3f::operator+ | ( | const float | f | ) | const |
◆ operator+() [2/2]
◆ operator+=() [1/2]
ofVec3f & ofVec3f::operator+= | ( | const float | f | ) |
Adds a float value 'f' to 'x', 'y' and 'z' members.
◆ operator+=() [2/2]
◆ operator-() [1/3]
ofVec3f ofVec3f::operator- | ( | ) | const |
◆ operator-() [2/3]
ofVec3f ofVec3f::operator- | ( | const float | f | ) | const |
◆ operator-() [3/3]
◆ operator-=() [1/2]
ofVec3f & ofVec3f::operator-= | ( | const float | f | ) |
Subtract a float value 'f' from 'x', 'y', and 'z' members.
◆ operator-=() [2/2]
◆ operator/() [1/2]
ofVec3f ofVec3f::operator/ | ( | const float | f | ) | const |
◆ operator/() [2/2]
◆ operator/=() [1/2]
ofVec3f & ofVec3f::operator/= | ( | const float | f | ) |
Scale this vector by dividing 'x', 'y' and 'z' members by 'f'.
◆ operator/=() [2/2]
◆ operator==()
bool ofVec3f::operator== | ( | const ofVec3f & | vec | ) | const |
◆ operator[]() [1/2]
|
inline |
Allows to access the individual components of an 'ofVec3f' as though it is an array.
This function can be handy if you want to do the same operation to all 'x', 'y' and 'z' components, as it means you can just make a 'for' loop that repeats 3 times.
◆ operator[]() [2/2]
|
inline |
◆ perpendicular()
Construct a plane using this vector and 'vec' (by finding the plane that both lie on), and set our 'x', 'y' and 'z' to be the vector that is perpendicular to the constructed plane (the normal to the plane).
This method is usually used to calculate a normal vector to a surface, which can then be used to calculate lighting, collisions, and other 3D effects.
◆ rotate() [1/3]
◆ rotate() [2/3]
Rotates this vector by 'angle' degrees about the axis specified by 'axis', using 'pivot' as the origin of rotation.
◆ rotate() [3/3]
ofVec3f & ofVec3f::rotate | ( | float | ax, |
float | ay, | ||
float | az | ||
) |
Performs an Euler rotation of this vector by 'ax' degrees about the x axis, 'ay' degrees about the y axis, and 'az' degrees about the z axis.
Watch out for gimbal lock when specifying multiple rotations in the same call.
◆ rotateRad() [1/3]
◆ rotateRad() [2/3]
Rotates this vector by 'angle' radians around the axis specified by 'axis', using 'pivot' as the origin of rotation.
◆ rotateRad() [3/3]
ofVec3f & ofVec3f::rotateRad | ( | float | ax, |
float | ay, | ||
float | az | ||
) |
Performs an Euler rotation of this vector by 'ax' radians about the x axis, 'ay' radians about the y axis, and 'az' radians about the z axis.
Watch out for gimbal lock when specifying multiple rotations in the same call.
◆ scale()
ofVec3f & ofVec3f::scale | ( | const float | length | ) |
Scales this vector up or down so that it has the requested length.
◆ set() [1/3]
void ofVec3f::set | ( | const ofVec3f & | vec | ) |
◆ set() [2/3]
void ofVec3f::set | ( | float | _scalar | ) |
◆ set() [3/3]
void ofVec3f::set | ( | float | x, |
float | y, | ||
float | z = 0 |
||
) |
◆ squareDistance()
float ofVec3f::squareDistance | ( | const ofVec3f & | pnt | ) | const |
Treats both this vector and 'pnt' as points in 3D space, and calculates and returns the squared distance between them.
Use as a much faster alternative to distance() if you don't need to know an exact number but rather just a rough idea of distance (for example when finding the shortest distance of a bunch of points to a reference point, where it doesn't matter exactly what the distances are, you just want the shortest). It avoids the square root calculation that is ordinarily required to calculate a length.
Member Data Documentation
◆ x
float ofVec3f::x |
Stores the X
component of this vector.
◆ y
float ofVec3f::y |
Stores the Y
component of this vector.
◆ z
float ofVec3f::z |
Stores the Z
component of this vector.
The documentation for this class was generated from the following file:
- /Users/icq4ever/Desktop/oF0120/libs/openFrameworks/math/ofVec3f.h