Data Structures | Functions
AtVector API

Vector math types and their related utilities. More...

Data Structures

struct  AtVector
 3D point (single precision) More...
 
struct  AtVector2
 2D point More...
 
struct  AtHPoint
 Homogeneous point. More...
 
struct  AtVectorDv
 Vector with differentials. More...
 

Functions

AI_DEVICE constexpr AtVector operator* (float f, const AtVector &p)
 
AI_DEVICE constexpr AtVector operator+ (float f, const AtVector &p)
 
AI_DEVICE constexpr AtVector operator- (float f, const AtVector &p)
 
AI_DEVICE AtBooleanMask< 3 > operator< (const AtVector &lhs, float f)
 
AI_DEVICE AtBooleanMask< 3 > operator<= (const AtVector &lhs, float f)
 
AI_DEVICE AtBooleanMask< 3 > operator> (const AtVector &lhs, float f)
 
AI_DEVICE AtBooleanMask< 3 > operator>= (const AtVector &lhs, float f)
 
AI_DEVICE AtBooleanMask< 3 > operator< (const AtVector &lhs, const AtVector &rhs)
 
AI_DEVICE AtBooleanMask< 3 > operator<= (const AtVector &lhs, const AtVector &rhs)
 
AI_DEVICE AtBooleanMask< 3 > operator> (const AtVector &lhs, const AtVector &rhs)
 
AI_DEVICE AtBooleanMask< 3 > operator>= (const AtVector &lhs, const AtVector &rhs)
 
AI_DEVICE constexpr AtVector2 operator* (float f, const AtVector2 &p)
 
AI_DEVICE constexpr AtVector2 operator+ (float f, const AtVector2 &p)
 
AI_DEVICE constexpr AtVector2 operator- (float f, const AtVector2 &p)
 
AI_DEVICE AtBooleanMask< 2 > operator< (const AtVector2 &lhs, float f)
 
AI_DEVICE AtBooleanMask< 2 > operator<= (const AtVector2 &lhs, float f)
 
AI_DEVICE AtBooleanMask< 2 > operator> (const AtVector2 &lhs, float f)
 
AI_DEVICE AtBooleanMask< 2 > operator>= (const AtVector2 &lhs, float f)
 
AI_DEVICE AtBooleanMask< 2 > operator< (const AtVector2 &lhs, const AtVector2 &rhs)
 
AI_DEVICE AtBooleanMask< 2 > operator<= (const AtVector2 &lhs, const AtVector2 &rhs)
 
AI_DEVICE AtBooleanMask< 2 > operator> (const AtVector2 &lhs, const AtVector2 &rhs)
 
AI_DEVICE AtBooleanMask< 2 > operator>= (const AtVector2 &lhs, const AtVector2 &rhs)
 

Vector Components

#define AI_X   0
 X component.
 
#define AI_Y   1
 Y component.
 
#define AI_Z   2
 Z component.
 

2D Vector Operations

AI_DEVICE constexpr float AiV2Dot (const AtVector2 &v1, const AtVector2 &v2)
 Dot product: <v1, v2>
 
AI_DEVICE float AiV2Length (const AtVector2 &v1)
 Vector Length: ||v1||.
 
float AiV2Dist (const AtVector2 &p1, const AtVector2 &p2)
 Distance between two points: ||p1-p2||.
 
constexpr AtVector2 AiV2Lerp (float t, const AtVector2 &lo, const AtVector2 &hi)
 2D vector linear interpolation (t=0 -> result=lo, t=1 -> result=hi)
 
constexpr AtVector2 AiV2Clamp (const AtVector2 &in, float lo, float hi)
 Clamp each vector coordinate to the range [lo,hi].
 
AI_DEVICE AtVector2 ABS (const AtVector2 &a)
 Absolute value of each component.
 
AI_DEVICE float AiMaxElement (const AtVector2 &a)
 Element-wise max.
 
float AiMinElement (const AtVector2 &a)
 Element-wise min.
 

3D Vector Operations

AI_DEVICE float AiV3Length (const AtVector &a)
 Vector Length: ||a||.
 
AI_DEVICE constexpr float AiV3Dot (const AtVector &a, const AtVector &b)
 Dot product: <a, b>
 
AI_DEVICE float AiV3Dist (const AtVector &a, const AtVector &b)
 Distance between two points: ||a-b||.
 
AI_DEVICE constexpr float AiV3Dist2 (const AtVector &a, const AtVector &b)
 Squared distance between two points: ||a-b||^2.
 
AI_DEVICE constexpr float AiV3DistPlane (const AtVector &x, const AtVector &p, const AtVector &n)
 Signed distance between point x and a plane defined by point p and normalized vector n.
 
AI_DEVICE constexpr AtVector AiV3Cross (const AtVector &a, const AtVector &b)
 Cross product: a x b.
 
AI_DEVICE AtVector AiV3Normalize (const AtVector &a)
 Normalize a vector: a / ||a||.
 
AI_DEVICE constexpr AtVector AiV3Lerp (float t, const AtVector &lo, const AtVector &hi)
 3D vector linear interpolation (t=0 -> result=lo, t=1 -> result=hi)
 
AI_DEVICE constexpr AtVector AiV3Clamp (const AtVector &in, float lo, float hi)
 Clamp each vector coordinate to the range [lo,hi].
 
AI_DEVICE constexpr AtVector AiV3Min (const AtVector &a, const AtVector &b)
 Minimum of two vectors, component-wise.
 
AI_DEVICE constexpr AtVector AiV3Max (const AtVector &a, const AtVector &b)
 Maximum of two vectors, component-wise.
 
AI_DEVICE AtVector ABS (const AtVector &a)
 Absolute value of each component.
 
AI_DEVICE float AiMaxElement (const AtVector &a)
 Element-wise max.
 
AI_DEVICE float AiMinElement (const AtVector &a)
 Element-wise min.
 
AI_DEVICE AtVector AiBerpXYZ (float a, float b, const AtVector &p0, const AtVector &p1, const AtVector &p2)
 Barycentric interpolation of a point inside a triangle.
 
AI_API AI_DEVICE AI_PURE bool AiV3IsFinite (const AtVector &a)
 Check whether a vector has all valid components (not NaN and not infinite)
 
AI_DEVICE bool AiV3IsSmall (const AtVector &a, float epsilon=AI_EPSILON)
 Check for a zero vector, within a small tolerance: ||a|| < epsilon.
 
AI_DEVICE void AiV3RotateToFrame (AtVector &a, const AtVector &u, const AtVector &v, const AtVector &w)
 Rotate vector a so that it aligns with frame {u,v,w}.
 
AI_DEVICE void AiBerpUV (float a, float b, float u0, float v0, float u1, float v1, float u2, float v2, float *u, float *v)
 Barycentric interpolation of UV coordinates inside a 3D triangle.
 

4D Vector Operations

AI_DEVICE AtHPoint AiV4CreatePoint (const AtVector &v)
 Create a 4D point: pout = (v.x, v.y, v.z, 1)
 
AI_DEVICE AtHPoint AiV4CreateVector (const AtVector &v)
 Create a 4D vector: vout = (v.x, v.y, v.z, 0)
 
AI_DEVICE void AiV4CreatePoint (AtHPoint &pout, const AtVector &v)
 
void AiV4CreateVector (AtHPoint &vout, const AtVector &v)
 Create a 4D vector: vout = (v.x, v.y, v.z, 0)
 
void AiV4Add (AtHPoint &vout, const AtHPoint &v1, const AtHPoint &v2)
 Add two vectors: vout = v1 + v2.
 
void AiV4Sub (AtHPoint &vout, const AtHPoint &v1, const AtHPoint &v2)
 Substract two vectors: vout = v1 - v2.
 
void AiV4Scale (AtHPoint &vout, const AtHPoint &vin, float k)
 Scale a vector by a constant: vout = vin * k.
 
void AiV4Neg (AtHPoint &vout, const AtHPoint &vin)
 Negate a vector: vout = -vin.
 
void AiV4Project (AtVector &vout, const AtHPoint &vin)
 Project a homogeneous vector back into 3d: vout = vin.w != 0 ? vin * (1 / vin.w) : (0,0,0)
 
AI_API AI_DEVICE void AiV3BuildLocalFrame (AtVector &u, AtVector &v, const AtVector &N)
 Build an orthonormal basis aligned with vector N (Frisvad's method). More...
 
AI_API AI_DEVICE void AiV3BuildLocalFramePolar (AtVector &u, AtVector &v, const AtVector &N)
 Build an orthonormal basis aligned with vector N (polar method). More...
 

Detailed Description

Vector math types and their related utilities.

Function Documentation

AI_API AI_DEVICE void AiV3BuildLocalFrame ( AtVector U,
AtVector V,
const AtVector N 
)

Build an orthonormal basis aligned with vector N (Frisvad's method).

This is Frisvad's method of building a local reference frame (U,V,W), where W = N. This method is discontinuous at the Z = 0 plane.

Parameters
[out]Unormalized U basis vector
[out]Vnormalized V basis vector
Nnormalized vector that will serve as our W basis vector (usually this is a surface normal)
AI_API AI_DEVICE void AiV3BuildLocalFramePolar ( AtVector U,
AtVector V,
const AtVector N 
)

Build an orthonormal basis aligned with vector N (polar method).

Builds local reference frame (U,V,W), where W = N. Uses the parametric tangent vectors in polar coordinates. This is continuous all across the sphere but at the poles.

Parameters
[out]Unormalized U basis vector
[out]Vnormalized V basis vector
Nnormalized vector that will serve as our W basis vector (usually this is a surface normal)

© 2020 Autodesk, Inc. · All rights reserved · www.arnoldrenderer.com