3DCoat  3D-COAT 4.9.xx
3DCoat is the one application that has all the tools you need to take your 3D idea from a block of digital clay all the way to a production ready, fully textured organic or hard surface model.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
coat::scripto::Vec3 Class Reference

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

#include <SVec3.h>

Public Member Functions

 Vec3 ()
 Constructor for building a zero vector. More...
 
 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. More...
 
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...
 
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
 

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 };

Constructor & Destructor Documentation

coat::scripto::Vec3::Vec3 ( )
inline

Constructor for building a zero vector.

Referenced by operator-().

Member Function Documentation

Vec3& coat::scripto::Vec3::abs ( )
inline

Set values of the vector to absolute.

Vec3 a( -45, 70, -80 );
a.abs();

References absCopy().

Vec3 coat::scripto::Vec3::absCopy ( ) const
inline
See Also
abs()

Referenced by abs().

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 );
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 );

References clampCopy().

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 ) );

References clampCopy().

Vec3 coat::scripto::Vec3::clampCopy ( float  min,
float  max 
) const
inline
See Also
clamp( float, float )

Referenced by clamp().

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 );

References crossCopy().

Vec3 coat::scripto::Vec3::crossCopy ( const Vec3 b) const
inline
See Also
cross()

Referenced by cross().

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::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()

References lerpCopy().

Vec3 coat::scripto::Vec3::lerpCopy ( const Vec3 b,
float  s 
) const
inline
See Also
lerp()

Referenced by 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 );

References maxCopy().

Vec3 coat::scripto::Vec3::maxCopy ( const Vec3 b) const
inline
See Also
max()

Referenced by 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 );

References minCopy().

Vec3 coat::scripto::Vec3::minCopy ( const Vec3 b) const
inline
See Also
min()

Referenced by min().

Vec3& coat::scripto::Vec3::normalize ( )
inline

Normalize the vector.

Vec3 a( 45, 70, 80 );
a.normalize();
See Also
normalized()

References normalizeCopy().

Vec3 coat::scripto::Vec3::normalizeCopy ( ) const
inline
See Also
normalize()

Referenced by normalize().

bool coat::scripto::Vec3::normalized ( ) const
inline

Returns TRUE then the vector is normalized.

See Also
normalized()
coat::scripto::Vec3::operator std::string ( ) const

Ability for converting Vec3 to string.

Vec3 a( 45, 70, 80 );
string m = string( a );
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::operator- ( ) const
inline

Negation operator.

Vec3 a( 45, 70, 80 );
Vec3 na = -a;

References Vec3().

bool coat::scripto::Vec3::operator== ( const Vec3 b) const
inline

Comparison.

Vec3 a;
...
if (a == Vec3( 5, 70, 80 )) { ... }
Vec3& coat::scripto::Vec3::reflect ( const Vec3 normal)
inline

Calculates a reflected vector by normal.

vec3-reflect.png
See Also
refract()

References reflectCopy().

Vec3 coat::scripto::Vec3::reflectCopy ( const Vec3 normal) const
inline
See Also
reflect()

Referenced by 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()

References refractCopy().

Vec3 coat::scripto::Vec3::refractCopy ( const Vec3 normal,
float  eta 
) const
inline
See Also
refract()

Referenced by refract().

Vec3& coat::scripto::Vec3::round ( )
inline

Returns rounded vector.

Vec3 a( 45.6, 70.7, 80.8 );
a.round();
See Also
normalized()

References roundCopy().

Vec3 coat::scripto::Vec3::roundCopy ( ) const
inline
See Also
round()

Referenced by round().

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()

References slerpCopy().

Vec3 coat::scripto::Vec3::slerpCopy ( const Vec3 b,
float  s 
) const
inline
See Also
slerp()

Referenced by 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 );

References truncateCopy().

Vec3 coat::scripto::Vec3::truncateCopy ( float  length) const
inline
See Also
truncate()

Referenced by truncate().

float coat::scripto::Vec3::x ( ) const
inline

Getter for x.

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

Getter for y.

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

Getter for z.

See Also
x(), y()
bool coat::scripto::Vec3::zero ( ) const
inline

Returns TRUE then the all values of the vector is zero.


The documentation for this class was generated from the following files: