![]() |
CUGL 4.0
Cornell University Game Library
|
#include <CUSpinor.h>
Public Member Functions | |
| Spinor () | |
| Spinor (float angle) | |
| Spinor (float real, float complex) | |
| Spinor & | operator= (float angle) |
| Spinor & | set (float angle) |
| Spinor & | set (float real, float complex) |
| Spinor & | set (const Spinor s) |
| Spinor & | scale (float t) |
| Spinor & | add (const Spinor other) |
| Spinor & | add (float angle) |
| Spinor & | subtract (const Spinor other) |
| Spinor & | subtract (float angle) |
| Spinor & | multiply (const Spinor other) |
| Spinor & | operator*= (float t) |
| Spinor & | operator*= (const Spinor other) |
| Spinor & | operator+= (const Spinor other) |
| Spinor & | operator+= (float angle) |
| Spinor & | operator-= (const Spinor other) |
| Spinor & | operator-= (float angle) |
| Spinor | operator* (float t) |
| Spinor | operator* (const Spinor other) |
| const Spinor | operator+ (const Spinor other) const |
| Spinor | operator+ (float angle) |
| Spinor & | operator- (const Spinor other) |
| Spinor | operator- (float angle) |
| float | getAngle () const |
| bool | isZero () const |
| bool | isNearZero (float epsilon=CU_MATH_EPSILON) const |
| float | length () const |
| float | lengthSquared () const |
| Spinor & | normalize () |
| Spinor | getNormalization () const |
| Spinor & | invert () |
| Spinor | getInverse () |
| Spinor & | lerp (Spinor dst, float t) |
| Spinor & | slerp (Spinor dst, float t) |
| std::string | toString (bool verbose=false) const |
| operator std::string () const | |
| Spinor (const Vec2 &v) | |
| Spinor & | operator= (const Vec2 &v) |
| Spinor & | operator+= (const Vec2 &right) |
| Spinor & | operator-= (const Vec2 &right) |
| const Spinor | operator+ (const Vec2 &right) const |
| const Spinor | operator- (const Vec2 &right) const |
| operator Vec2 () const | |
Public Attributes | |
| float | real |
| float | complex |
This class represents a spinor, which is often useful for lighting.
Spinors represent an angle about the origin, but behave like a mobius strip when rotated. For information on how spinors work, see
https://en.wikipedia.org/wiki/Spinor
For the most part, this class works like a complex number with additional methods representing the spinor characteristics.
|
inline |
Creates the 0 spinor
|
inline |
Creates a spinor for the given angle (in radians)
| angle | The spinor angle |
|
inline |
Creates a spinor with the given real and imaginary parts
| real | The real component |
| complex | The imaginary component |
|
explicit |
Creates a spinor from the given vector.
The x is converted to the real component and y to complex.
| v | The vector to convert |
Adds the given spinor to this one.
| other | The spinor to add |
| Spinor & cugl::Spinor::add | ( | float | angle | ) |
Adds the given angle to this spinor.
This is the same as adding a spinor of the given angle.
| angle | The angle to add |
| float cugl::Spinor::getAngle | ( | ) | const |
Returns the angle represented by this spinor
|
inline |
Returns the inverse of this spinor.
|
inline |
Returns a normalized copy of this spinor.
This method creates a copy of this spinor that is of unit length (i.e. the length of the spinor after calling this method will be 1.0f). If the spinor already has unit length or if the length of the spinor is zero, this method does nothing.
Note: this does not modify this spinor.
| Spinor & cugl::Spinor::invert | ( | ) |
Sets this spinor to its inverse.
|
inline |
Returns true if this spinor is with tolerance of the origin.
| epsilon | The comparison tolerance |
|
inline |
Returns true this spinor contains all zeros.
|
inline |
|
inline |
Returns the squared spinor of this vector.
This method is faster than spinor because it does not need to compute a square root. Hence it is best to us this method when it is not necessary to get the exact length of a spinor (e.g. when simply comparing the length to a threshold value).
{
Linearly interpolates this spinor with the given end result
| dst | The target spinor |
| t | The interpolation factor |
Multiplies this spinor by the given one.
| other | The spinor to multiply |
| Spinor & cugl::Spinor::normalize | ( | ) |
Normalizes this spinor.
This method normalizes the spinor so that it is of unit length (i.e. the length of the spinor after calling this method will be 1.0f). If the spinor already has unit length or if the length of the spinor is zero, this method does nothing.
|
inline |
Cast from Spinor to a string.
Returns the product this spinor by the given one.
Note: this does not modify this spinor.
| other | The spinor to multiply |
|
inline |
Returns the scale this spinor by the given factor
Note: this does not modify this spinor.
| t | The scaling factor |
Multiplies this spinor by the given one.
| other | The spinor to multiply |
|
inline |
Scales this spinor by the given factor
| t | The scaling factor |
Returns the sum of this spinor with the given spinor.
Note: this does not modify this spinor.
| other | The spinor to add. |
Returns the sum of this spinor with the given vector.
Note: this does not modify this spinor.
| right | The vector to add. |
|
inline |
Returns the sum of this spinor with the given angle.
This is the same as adding a spinor of the given angle. Note: this does not modify this spinor.
| angle | The angle to add |
Adds the given spinor to this one.
| other | The spinor to add |
Adds the given vector from this spinor in place.
| right | The vector to add |
|
inline |
Adds the given angle to this spinor.
This is the same as adding a spinor of the given angle.
| angle | The angle to add |
Returns the result of subtracting the given spinor from this one.
Note: this does not modify this spinor.
| other | The spinor to subtract |
Returns the difference of this spinor with the given vector.
Note: this does not modify this spinor.
| right | The vector to subtract. |
|
inline |
Returns the result of subtracting the given angle from this spinor.
This is the same as subtracting a spinor of the given angle.
| angle | The angle to subtract |
Subtracts the given spinor from this one.
| other | The spinor to subtract |
Subtracts the given vector from this spinor in place.
| right | The vector to subtract |
|
inline |
Subtracts the given angle from this spinor.
This is the same as subtracting a spinor of the given angle.
| angle | The angle to subtract |
Sets the values of this spinor to those of the given vector.
The x is converted to the real component and y to complex.
| v | The vector to convert |
|
inline |
Sets the spinor to have the given angle (in radians)
| angle | The spinor angle |
|
inline |
Scales this spinor by the given factor
| t | The scaling factor |
Sets the spinor to be a copy of the given one
| s | The spinor to copy. |
| Spinor & cugl::Spinor::set | ( | float | angle | ) |
Sets the spinor to have the given angle (in radians)
| angle | The spinor angle |
|
inline |
Sets the elements of this vector to the specified values.
| real | The real component |
| complex | The imaginary component |
Spherically interpolates this spinor with the given end result
| dst | The target spinor |
| t | The interpolation factor |
Subtracts the given spinor from this one.
| other | The spinor to subtract |
| Spinor & cugl::Spinor::subtract | ( | float | angle | ) |
Subtracts the given angle from this spinor.
This is the same as subtracting a spinor of the given angle.
| angle | The angle to subtract |
| std::string cugl::Spinor::toString | ( | bool | verbose = false | ) | const |
Returns a string representation of this spinor for debugging purposes.
If verbose is true, the string will include class information. This allows us to unambiguously identify the class.
| verbose | Whether to include class information |
| float cugl::Spinor::complex |
The imaginary component
| float cugl::Spinor::real |
The real component