|
SmartFoxServer 3 C++ Client API 3.1.0-beta
Client API for SmartFoxServer 3
|
A class representing a Vector in 3D space. More...
#include <SFSVector3.h>
Public Member Functions | |
| float | lengthSquared () const |
| Returns the squared length of this vector. | |
| float | length () const |
| Returns the length (magnitude) of this vector. | |
| bool | isNormalized () const |
| Returns true if the vector is normalized, i.e. | |
| SFSVector3 | sum (const SFSVector3 &vec) const |
| Returns a new vector that is the sum of this vector and the specified vector. | |
| SFSVector3 | sub (const SFSVector3 &vec) const |
| Returns a new vector that is the result of subtracting the specified vector from this vector. | |
| SFSVector3 | mult (const SFSVector3 &vec) const |
| Returns a new vector that is the component-wise multiplication of this vector and the specified vector. | |
| SFSVector3 | divide (const SFSVector3 &vec) const |
| Returns a new vector that is the component-wise division of this vector by the specified vector. | |
| SFSVector3 | normalize () const |
| Returns a new vector that is the normalized (unit length) version of this vector. | |
| float | dot (const SFSVector3 &vec) const |
| Returns the dot product of this vector and the specified vector. | |
| SFSVector3 | cross (const SFSVector3 &vec) const |
| Returns the cross product of this vector and the specified vector. | |
| float | distanceTo (const SFSVector3 &vec) const |
| Returns the Euclidean distance between this vector and the specified vector. | |
| float | distanceSquaredTo (const SFSVector3 &vec) const |
| Returns the squared distance between this vector and the specified vector. | |
| SFSVector3 | abs () const |
| Returns a new vector with all components in absolute values. | |
| SFSVector3 | min (const SFSVector3 &vec) const |
| Returns a new vector with the component-wise minimum of this vector and the specified vector. | |
| SFSVector3 | max (const SFSVector3 &vec) const |
| Returns a new vector with the component-wise maximum of this vector and the specified vector. | |
| SFSVector3 | floor () const |
| Returns a new vector with all components rounded down to the nearest integer. | |
| SFSVector3 | ceil () const |
| Returns a new vector with all components rounded up to the nearest integer. | |
| SFSVector3 | round () const |
| Returns a new vector with all components rounded to the nearest integer, with halfway cases rounded towards positive infinity (-1.5 rounds to -1.0). | |
| SFSVector3 | lerp (const SFSVector3 &vec, float weight) const |
| Returns the result of the linear interpolation between this vector and the specified vector by the specified weight. | |
| SFSVector3 | rotate (const SFSVector3 &axis, float angle) const |
| Returns a new vector that is the result of rotating this vector around the specified axis by the specified angle, using Rodrigues' rotation formula. | |
A class representing a Vector in 3D space.
NOTE: equality and hashing are value-based (x,y,z); mutating a component while the instance is used as a key in a hash-based container will corrupt lookups.
|
inline |
Returns the squared length of this vector.
Cheaper than length(), and enough whenever lengths are only compared to each other.
|
inline |
Returns the length (magnitude) of this vector.
|
inline |
Returns true if the vector is normalized, i.e.
its length is approximately equal to 1.
|
inline |
Returns a new vector that is the sum of this vector and the specified vector.
| vec | the vector to add |
|
inline |
Returns a new vector that is the result of subtracting the specified vector from this vector.
| vec | the vector to subtract |
|
inline |
Returns a new vector that is the component-wise multiplication of this vector and the specified vector.
| vec | the vector to multiply with |
|
inline |
Returns a new vector that is the component-wise division of this vector by the specified vector.
If any component of the divisor is zero, the result will be Infinity or NaN.
| vec | the vector to divide by |
|
inline |
Returns a new vector that is the normalized (unit length) version of this vector.
If this vector has zero length, returns a zero vector.
|
inline |
Returns the dot product of this vector and the specified vector.
The dot product will be 0 for a right angle (90 degrees), greater than 0 for angles narrower than 90 degrees and lower than 0 for angles wider than 90 degrees. When using unit (normalized) vectors, the result will always be between -1.0 (180 degree angle) when the vectors are facing opposite directions, and 1.0 (0 degree angle) when the vectors are aligned.
| vec | the vector to compute the dot product with |
|
inline |
Returns the cross product of this vector and the specified vector.
The cross product is a vector perpendicular to both vectors.
| vec | the vector to compute the cross product with |
|
inline |
Returns the Euclidean distance between this vector and the specified vector.
| vec | the vector to measure distance to |
|
inline |
Returns the squared distance between this vector and the specified vector.
This is more efficient than distanceTo() when comparing distances.
| vec | the vector to measure squared distance to |
|
inline |
Returns a new vector with all components in absolute values.
|
inline |
Returns a new vector with the component-wise minimum of this vector and the specified vector.
| vec | the vector to compare with |
|
inline |
Returns a new vector with the component-wise maximum of this vector and the specified vector.
| vec | the vector to compare with |
|
inline |
Returns a new vector with all components rounded down to the nearest integer.
|
inline |
Returns a new vector with all components rounded up to the nearest integer.
|
inline |
Returns a new vector with all components rounded to the nearest integer, with halfway cases rounded towards positive infinity (-1.5 rounds to -1.0).
|
inline |
Returns the result of the linear interpolation between this vector and the specified vector by the specified weight.
The weight range is 0.0 to 1.0, representing the amount of interpolation. Values outside this range will extrapolate.
| vec | the target vector to interpolate towards |
| weight | the interpolation weight (0.0 = this vector, 1.0 = target vector) |
| SFSVector3 sfs3::entities::SFSVector3::rotate | ( | const SFSVector3 & | axis, |
| float | angle ) const |
Returns a new vector that is the result of rotating this vector around the specified axis by the specified angle, using Rodrigues' rotation formula.
The axis must be a normalized vector: if it isn't, no rotation is applied and a copy of this vector is returned unchanged (a warning is logged).
| axis | the axis to rotate around (must be a normalized vector) |
| angle | the angle to rotate by, in radians |