NVIDIA OptiX 6.5 API nvidia_logo_transpbg.gif Up
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
optix::Matrix< M, N > Class Template Reference

Public Types

typedef VectorDim< N >::VectorType floatN
 
typedef VectorDim< M >::VectorType floatM
 

Public Member Functions

RT_HOSTDEVICE Matrix ()
 
RT_HOSTDEVICE Matrix (const float data[M *N])
 
RT_HOSTDEVICE Matrix (const Matrix &m)
 
RT_HOSTDEVICE Matrixoperator= (const Matrix &b)
 
RT_HOSTDEVICE float operator[] (unsigned int i) const
 
RT_HOSTDEVICE float & operator[] (unsigned int i)
 
RT_HOSTDEVICE floatN getRow (unsigned int m) const
 
RT_HOSTDEVICE floatM getCol (unsigned int n) const
 
RT_HOSTDEVICE float * getData ()
 
RT_HOSTDEVICE const float * getData () const
 
RT_HOSTDEVICE void setRow (unsigned int m, const floatN &r)
 
RT_HOSTDEVICE void setCol (unsigned int n, const floatM &c)
 
RT_HOSTDEVICE Matrix< N, M > transpose () const
 
RT_HOSTDEVICE Matrix< 4, 4 > inverse () const
 
RT_HOSTDEVICE float det () const
 
RT_HOSTDEVICE bool operator< (const Matrix< M, N > &rhs) const
 
template<>
OPTIXU_INLINE RT_HOSTDEVICE float det () const
 
template<>
OPTIXU_INLINE RT_HOSTDEVICE float det () const
 
template<>
OPTIXU_INLINE RT_HOSTDEVICE
Matrix< 4, 4 > 
inverse () const
 
template<>
OPTIXU_INLINE RT_HOSTDEVICE
Matrix< 4, 4 > 
rotate (const float radians, const float3 &axis)
 
template<>
OPTIXU_INLINE RT_HOSTDEVICE
Matrix< 4, 4 > 
translate (const float3 &vec)
 
template<>
OPTIXU_INLINE RT_HOSTDEVICE
Matrix< 4, 4 > 
scale (const float3 &vec)
 
template<>
OPTIXU_INLINE RT_HOSTDEVICE
Matrix< 4, 4 > 
fromBasis (const float3 &u, const float3 &v, const float3 &w, const float3 &c)
 

Static Public Member Functions

static RT_HOSTDEVICE Matrix< 4, 4 > rotate (const float radians, const float3 &axis)
 
static RT_HOSTDEVICE Matrix< 4, 4 > translate (const float3 &vec)
 
static RT_HOSTDEVICE Matrix< 4, 4 > scale (const float3 &vec)
 
static RT_HOSTDEVICE Matrix< 4, 4 > fromBasis (const float3 &u, const float3 &v, const float3 &w, const float3 &c)
 
static RT_HOSTDEVICE Matrix< N, N > identity ()
 

Detailed Description

template<unsigned int M, unsigned int N>
class optix::Matrix< M, N >

A matrix with M rows and N columns.

Description

Matrix provides a utility class for small-dimension floating-point matrices, such as transformation matrices. Matrix may also be useful in other computation and can be used in both host and device code. Typedefs are provided for 2x2 through 4x4 matrices.

History

Matrix was introduced in OptiX 1.0.

See also rtVariableSetMatrix*

Constructor & Destructor Documentation

template<unsigned int M, unsigned int N>
OPTIXU_INLINE RT_HOSTDEVICE optix::Matrix< M, N >::Matrix ( )

A column of the matrix.

Create an uninitialized matrix

template<unsigned int M, unsigned int N>
RT_HOSTDEVICE optix::Matrix< M, N >::Matrix ( const float  data[M *N])
inlineexplicit

Create a matrix from the specified float array

template<unsigned int M, unsigned int N>
OPTIXU_INLINE RT_HOSTDEVICE optix::Matrix< M, N >::Matrix ( const Matrix< M, N > &  m)

Copy the matrix

Member Function Documentation

template<unsigned int M, unsigned int N>
RT_HOSTDEVICE float optix::Matrix< M, N >::det ( ) const

Returns the determinant of the matrix

template<unsigned int M, unsigned int N>
static RT_HOSTDEVICE Matrix<4,4> optix::Matrix< M, N >::fromBasis ( const float3 &  u,
const float3 &  v,
const float3 &  w,
const float3 & 
)
static

Creates a matrix from an ONB and center point

template<unsigned int M, unsigned int N>
OPTIXU_INLINE RT_HOSTDEVICE Matrix< M, N >::floatM optix::Matrix< M, N >::getCol ( unsigned int  n) const

Access the specified column 0..N. Returns float, float2, float3 or float4 depending on the matrix size

template<unsigned int M, unsigned int N>
OPTIXU_INLINE RT_HOSTDEVICE float * optix::Matrix< M, N >::getData ( )

Returns a pointer to the internal data array. The data array is stored in row-major order.

template<unsigned int M, unsigned int N>
OPTIXU_INLINE RT_HOSTDEVICE const float * optix::Matrix< M, N >::getData ( ) const

Returns a const pointer to the internal data array. The data array is stored in row-major order.

template<unsigned int M, unsigned int N>
OPTIXU_INLINE RT_HOSTDEVICE Matrix< M, N >::floatN optix::Matrix< M, N >::getRow ( unsigned int  m) const

Access the specified row 0..M. Returns float, float2, float3 or float4 depending on the matrix size

template<unsigned int M, unsigned int N>
OPTIXU_INLINE RT_HOSTDEVICE Matrix< N, N > optix::Matrix< M, N >::identity ( )
static

Returns the identity matrix

template<unsigned int M, unsigned int N>
RT_HOSTDEVICE Matrix<4,4> optix::Matrix< M, N >::inverse ( ) const

Returns the inverse of the matrix

template<unsigned int M, unsigned int N>
OPTIXU_INLINE RT_HOSTDEVICE bool optix::Matrix< M, N >::operator< ( const Matrix< M, N > &  rhs) const

Ordered comparison operator so that the matrix can be used in an STL container

template<unsigned int M, unsigned int N>
OPTIXU_INLINE RT_HOSTDEVICE Matrix< M, N > & optix::Matrix< M, N >::operator= ( const Matrix< M, N > &  b)

Assignment operator

template<unsigned int M, unsigned int N>
RT_HOSTDEVICE float optix::Matrix< M, N >::operator[] ( unsigned int  i) const
inline

Access the specified element 0..N*M-1

template<unsigned int M, unsigned int N>
RT_HOSTDEVICE float& optix::Matrix< M, N >::operator[] ( unsigned int  i)
inline

Access the specified element 0..N*M-1

template<unsigned int M, unsigned int N>
static RT_HOSTDEVICE Matrix<4,4> optix::Matrix< M, N >::rotate ( const float  radians,
const float3 &  axis 
)
static

Returns a rotation matrix

template<unsigned int M, unsigned int N>
static RT_HOSTDEVICE Matrix<4,4> optix::Matrix< M, N >::scale ( const float3 &  vec)
static

Returns a scale matrix

template<unsigned int M, unsigned int N>
OPTIXU_INLINE RT_HOSTDEVICE void optix::Matrix< M, N >::setCol ( unsigned int  n,
const floatM
)

Assign the specified column 0..N. Takes a float, float2, float3 or float4 depending on the matrix size

template<unsigned int M, unsigned int N>
OPTIXU_INLINE RT_HOSTDEVICE void optix::Matrix< M, N >::setRow ( unsigned int  m,
const floatN & 
)

Assign the specified row 0..M. Takes a float, float2, float3 or float4 depending on the matrix size

template<unsigned int M, unsigned int N>
static RT_HOSTDEVICE Matrix<4,4> optix::Matrix< M, N >::translate ( const float3 &  vec)
static

Returns a translation matrix

template<unsigned int M, unsigned int N>
OPTIXU_INLINE RT_HOSTDEVICE Matrix< N, M > optix::Matrix< M, N >::transpose ( ) const

Returns the transpose of the matrix