|
SmartFoxServer 3 C++ Client API 3.1.0-beta
Client API for SmartFoxServer 3
|
A class representing a Vector in 2D space. More...
#include <SFSVector2.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. | |
| SFSVector2 | sum (const SFSVector2 &vec) const |
| Returns a new vector that is the sum of this vector and the specified vector. | |
| SFSVector2 | sub (const SFSVector2 &vec) const |
| Returns a new vector that is the result of subtracting the specified vector from this vector. | |
| SFSVector2 | mult (const SFSVector2 &vec) const |
| Returns a new vector that is the component-wise multiplication of this vector and the specified vector. | |
| SFSVector2 | divide (const SFSVector2 &vec) const |
| Returns a new vector that is the component-wise division of this vector by the specified vector. | |
| SFSVector2 | normalize () const |
| Returns a new vector that is the normalized (unit length) version of this vector. | |
| float | angle () const |
| Returns the angle of this vector in radians, measured from the positive x-axis. | |
| SFSVector2 | rotate (float angle) const |
| Returns a new vector that is the result of rotating this vector by the specified angle. | |
| float | dot (const SFSVector2 &vec) const |
| Returns the dot product of this vector and the specified vector. | |
| float | cross (const SFSVector2 &vec) const |
| Returns the 2D cross product (also known as the perpendicular dot product or wedge product) of this vector and the specified vector. | |
| float | distanceTo (const SFSVector2 &vec) const |
| Returns the Euclidean distance between this vector and the specified vector. | |
| float | distanceSquaredTo (const SFSVector2 &vec) const |
| Returns the squared distance between this vector and the specified vector. | |
| SFSVector2 | abs () const |
| Returns a new vector with all components in absolute values. | |
| SFSVector2 | min (const SFSVector2 &vec) const |
| Returns a new vector with the component-wise minimum of this vector and the specified vector. | |
| SFSVector2 | max (const SFSVector2 &vec) const |
| Returns a new vector with the component-wise maximum of this vector and the specified vector. | |
| SFSVector2 | floor () const |
| Returns a new vector with all components rounded down to the nearest integer. | |
| SFSVector2 | ceil () const |
| Returns a new vector with all components rounded up to the nearest integer. | |
| SFSVector2 | 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). | |
| SFSVector2 | lerp (const SFSVector2 &vec, float weight) const |
| Returns the result of the linear interpolation between this vector and the specified vector by the specified weight. | |
| float | aspect () const |
| Returns the aspect ratio of this vector, the ratio of x to y. | |
A class representing a Vector in 2D space.
NOTE: equality and hashing are value-based (x,y); 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 angle of this vector in radians, measured from the positive x-axis.
The returned angle is in the range [-PI, PI].
|
inline |
Returns a new vector that is the result of rotating this vector by the specified angle.
| angle | the angle to rotate by, in radians |
|
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 2D cross product (also known as the perpendicular dot product or wedge product) of this vector and the specified vector.
This returns a scalar representing the z-component of the 3D cross product when treating the 2D vectors as 3D vectors with z=0. The magnitude represents the area of the parallelogram formed by the two vectors. The sign indicates orientation: positive if vec is counterclockwise from this vector, negative if clockwise.
| 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) |
|
inline |
Returns the aspect ratio of this vector, the ratio of x to y.
If y is zero, the result will be Infinity, -Infinity, or NaN.