3DCoatScripting  4.8.31β
You can manage 3DСoat features with help of scripting
coat::scripto::Vec3 Class Reference

Class for working with Euclidean vectors in 3D-space. More...

Public Types

typedef comms::cVec< float, 3 > vec3_t
 

Public Member Functions

 Vec3 ()
 Constructor for building a zero vector.
 
const About & about () const
 
 operator std::string () const
 Ability for converting Vec3 to string. More...
 
bool operator== (const Vec3 &b) const
 Comparison. More...
 
bool normalized () const
 Returns TRUE then the vector is normalized. More...
 
bool zero () const
 Returns TRUE then the all values of the vector is zero.
 
Vec3operator() (int i, float value)
 Setter like array.
[ 0 ] is x
[ 1 ] is y
[ 2 ] is z
By analogy with Mat3 and Mat4. More...
 
float operator() (int i) const
 Getter like array. More...
 
Vec3x (const float &value)
 Setter for x. More...
 
float x () const
 Getter for x. More...
 
Vec3y (const float &value)
 Setter for y. More...
 
float y () const
 Getter for y. More...
 
Vec3z (const float &value)
 Setter for z. More...
 
float z () const
 Getter for z. More...
 
Vec3 operator- () const
 Negation operator. More...
 
Vec3operator+= (const Vec3 &b)
 
Vec3operator-= (const Vec3 &b)
 
Vec3operator*= (const Vec3 &b)
 
Vec3operator*= (const float &k)
 
Vec3operator/= (const Vec3 &b)
 
Vec3operator/= (const float &k)
 
Vec3 operator+ (const Vec3 &b) const
 
Vec3 operator- (const Vec3 &b) const
 
Vec3 operator* (const Vec3 &b) const
 
Vec3 operator* (const float &k) const
 
Vec3 operator/ (const Vec3 &b) const
 
Vec3 operator/ (const float &k) const
 
float angle (const Vec3 &b) const
 Calculates angle between this vector and vector b. More...
 
float distance (const Vec3 &b) const
 Calculates an Euclidean distance between this vector and vector b. More...
 
float dot (const Vec3 &b) const
 Returns a dot product. More...
 
float length () const
 Returns an Euclidean length. More...
 
float lengthSquared () const
 Returns a squared Euclidean length. More...
 
Vec3abs ()
 Set values of the vector to absolute. More...
 
Vec3 absCopy () const
 
Vec3clamp (float min, float max)
 Clamp values to diapason [min; max]. More...
 
Vec3 clampCopy (float min, float max) const
 
Vec3clamp (const Vec3 &min, const Vec3 &max)
 Clamp values to diapason [min; max]. More...
 
Vec3 clampCopy (const Vec3 &min, const Vec3 &max) const
 
Vec3cross (const Vec3 &b)
 Return a cross product. More...
 
Vec3 crossCopy (const Vec3 &b) const
 
Vec3lerp (const Vec3 &b, float s)
 Interpolates between vectors, using linear interpolation. More...
 
Vec3 lerpCopy (const Vec3 &b, float s) const
 
Vec3max (const Vec3 &b)
 Calculates a maximum between two vectors. More...
 
Vec3 maxCopy (const Vec3 &b) const
 
Vec3min (const Vec3 &b)
 Calculates a minimum between two vectors. More...
 
Vec3 minCopy (const Vec3 &b) const
 
Vec3normalize ()
 Normalize the vector. More...
 
Vec3 normalizeCopy () const
 
Vec3round ()
 Returns rounded vector. More...
 
Vec3 roundCopy () const
 
Vec3reflect (const Vec3 &normal)
 Calculates a reflected vector by normal. More...
 
Vec3 reflectCopy (const Vec3 &normal) const
 
Vec3refract (const Vec3 &normal, float eta)
 Calculates a refracted vector by normal and eta. More...
 
Vec3 refractCopy (const Vec3 &normal, float eta) const
 
Vec3slerp (const Vec3 &b, float s)
 Interpolates between vectors, using spherical linear interpolation. More...
 
Vec3 slerpCopy (const Vec3 &b, float s) const
 
Vec3transform (const Mat4 &)
 Transform by matrix m. More...
 
Vec3 transformCopy (const Mat4 &) const
 
Vec3truncate (float length)
 Truncate to length. More...
 
Vec3 truncateCopy (float length) const
 

Static Public Attributes

static const Vec3 ONE
 
static const Vec3 UNDEFINED
 
static const Vec3 ZERO
 

Detailed Description

Class for working with Euclidean vectors in 3D-space.

vec3.png
See Also
Vec2
Since
4.5.32
Vec3 a( 10, 30, 90 );
Vec3 b = { 10, 30, 90 };

Member Function Documentation

coat::scripto::Vec3::operator std::string ( ) const

Ability for converting Vec3 to string.

Vec3 a( 45, 70, 80 );
string m = string( a );
bool coat::scripto::Vec3::operator== ( const Vec3 b) const
inline

Comparison.

Vec3 a;
...
if (a == Vec3( 5, 70, 80 )) { ... }
bool coat::scripto::Vec3::normalized ( ) const
inline

Returns TRUE then the vector is normalized.

See Also
normalized()
Vec3& coat::scripto::Vec3::operator() ( int  i,
float  value 
)
inline

Setter like array.
[ 0 ] is x
[ 1 ] is y
[ 2 ] is z
By analogy with Mat3 and Mat4.

Vec3 a( 45, 70, 80 );
// setting `y` to 95
a[ 1, 95 ];
float coat::scripto::Vec3::operator() ( int  i) const
inline

Getter like array.

Vec3 a( 45, 70, 80 );
float x = a[ 0 ];
float y = a[ 1 ];
float z = a[ 2 ];
Vec3& coat::scripto::Vec3::x ( const float &  value)
inline

Setter for x.

Vec3 a( 45, 70, 80 );
a.x( 50 ).y( 75 ).z( 85 );
See Also
y( float ), z( float )
float coat::scripto::Vec3::x ( ) const
inline

Getter for x.

Vec3 a( 45, 70, 80 );
float v = a.x();
See Also
y(), z()
Vec3& coat::scripto::Vec3::y ( const float &  value)
inline

Setter for y.

See Also
x( float ), z( float )
float coat::scripto::Vec3::y ( ) const
inline

Getter for y.

See Also
x(), z()
Vec3& coat::scripto::Vec3::z ( const float &  value)
inline

Setter for z.

See Also
x( float ), y( float )
float coat::scripto::Vec3::z ( ) const
inline

Getter for z.

See Also
x(), y()
Vec3 coat::scripto::Vec3::operator- ( ) const
inline

Negation operator.

Vec3 a( 45, 70, 80 );
Vec3 na = -a;
float coat::scripto::Vec3::angle ( const Vec3 b) const
inline

Calculates angle between this vector and vector b.

Vec3 a( 45, 70, 80 );
Vec3 b( 50, 75, 85 );
float theta = a.angle( b );
float coat::scripto::Vec3::distance ( const Vec3 b) const
inline

Calculates an Euclidean distance between this vector and vector b.

Vec3 a( 45, 70, 80 );
Vec3 b( 50, 75, 85 );
float r = a.distance( b );
float coat::scripto::Vec3::dot ( const Vec3 b) const
inline

Returns a dot product.

Vec3 a( 45, 70, 80 );
Vec3 b( 50, 75, 85 );
float r = a.dot( b );
float coat::scripto::Vec3::length ( ) const
inline

Returns an Euclidean length.

Vec3 a( 45, 70, 80 );
float r = a.length();
See Also
lengthSquared()
float coat::scripto::Vec3::lengthSquared ( ) const
inline

Returns a squared Euclidean length.

Vec3 a( 45, 70, 80 );
float r = a.lengthSquared();
See Also
length()
Vec3& coat::scripto::Vec3::abs ( )
inline

Set values of the vector to absolute.

Vec3 a( -45, 70, -80 );
a.abs();
Vec3 coat::scripto::Vec3::absCopy ( ) const
inline
See Also
abs()
Vec3& coat::scripto::Vec3::clamp ( float  min,
float  max 
)
inline

Clamp values to diapason [min; max].

Vec3 a( 45, 70, 80 );
...
a.clamp( 50, 100 );
Vec3 coat::scripto::Vec3::clampCopy ( float  min,
float  max 
) const
inline
Vec3& coat::scripto::Vec3::clamp ( const Vec3 min,
const Vec3 max 
)
inline

Clamp values to diapason [min; max].

Vec3 a( 45, 70, 80 );
...
a.clamp( Vec3( 0, 100, 0 ), Vec3( 50, 200, 50 ) );
Vec3 coat::scripto::Vec3::clampCopy ( const Vec3 min,
const Vec3 max 
) const
inline
Vec3& coat::scripto::Vec3::cross ( const Vec3 b)
inline

Return a cross product.

Vec3 a( 45, 70, 80 );
Vec3 b( 50, 75, 85 );
float r = a.cross( b );
Vec3 coat::scripto::Vec3::crossCopy ( const Vec3 b) const
inline
See Also
cross()
Vec3& coat::scripto::Vec3::lerp ( const Vec3 b,
float  s 
)
inline

Interpolates between vectors, using linear interpolation.

Vec3 a( 45, 70, 80 );
a.lerp( Vec3( 100 ), 0.3 );
See Also
slerp()
Vec3 coat::scripto::Vec3::lerpCopy ( const Vec3 b,
float  s 
) const
inline
See Also
lerp()
Vec3& coat::scripto::Vec3::max ( const Vec3 b)
inline

Calculates a maximum between two vectors.

Vec3 a( 45, 70, 80 );
Vec3 b( 15, 75, 85 );
a.max( b );
Vec3 coat::scripto::Vec3::maxCopy ( const Vec3 b) const
inline
See Also
max()
Vec3& coat::scripto::Vec3::min ( const Vec3 b)
inline

Calculates a minimum between two vectors.

Vec3 a( 45, 70, 80 );
Vec3 b( 15, 75, 85 );
a.min( b );
Vec3 coat::scripto::Vec3::minCopy ( const Vec3 b) const
inline
See Also
min()
Vec3& coat::scripto::Vec3::normalize ( )
inline

Normalize the vector.

Vec3 a( 45, 70, 80 );
a.normalize();
See Also
normalized()
Vec3 coat::scripto::Vec3::normalizeCopy ( ) const
inline
See Also
normalize()
Vec3& coat::scripto::Vec3::round ( )
inline

Returns rounded vector.

Vec3 a( 45.6, 70.7, 80.8 );
a.round();
See Also
normalized()
Vec3 coat::scripto::Vec3::roundCopy ( ) const
inline
See Also
round()
Vec3& coat::scripto::Vec3::reflect ( const Vec3 normal)
inline

Calculates a reflected vector by normal.

vec3-reflect.png
See Also
refract()
Vec3 coat::scripto::Vec3::reflectCopy ( const Vec3 normal) const
inline
See Also
reflect()
Vec3& coat::scripto::Vec3::refract ( const Vec3 normal,
float  eta 
)
inline

Calculates a refracted vector by normal and eta.

Parameters
etaRatio of indices of refraction at the surface.
See Also
reflect()
Vec3 coat::scripto::Vec3::refractCopy ( const Vec3 normal,
float  eta 
) const
inline
See Also
refract()
Vec3& coat::scripto::Vec3::slerp ( const Vec3 b,
float  s 
)
inline

Interpolates between vectors, using spherical linear interpolation.

Vec3 a( 45, 70, 80 );
a.slerp( Vec3( 100 ), 0.3 );
See Also
lerp()
Vec3 coat::scripto::Vec3::slerpCopy ( const Vec3 b,
float  s 
) const
inline
See Also
slerp()
Vec3 & coat::scripto::Vec3::transform ( const Mat4 m)

Transform by matrix m.

Vec3 a( 45, 70, 80 );
Mat4 m;
...
a.transform( m );
Vec3 coat::scripto::Vec3::transformCopy ( const Mat4 m) const
See Also
transform()
Vec3& coat::scripto::Vec3::truncate ( float  length)
inline

Truncate to length.

Vec3 a( 45, 70, 80 );
a.truncate( 10 );
Vec3 coat::scripto::Vec3::truncateCopy ( float  length) const
inline
See Also
truncate()