Nebula
Loading...
Searching...
No Matches
Math::vector Struct Reference

#include <vector.h>

Detailed Description

A vector is a 3D direction in space.

Represented as a __m128 with the W component being 0 at all times. Useful for representing normal vectors and directions.

Public Member Functions

 vector ()
 default constructor
 
 vector (scalar x, scalar y, scalar z)
 construct from values
 
 vector (scalar v)
 construct from single value
 
 vector (const vector &rhs)
 copy constructor
 
 vector (const vec3 &rhs)
 construct from vec3
 
 vector (const vec4 &rhs)
 construct from vec4
 
 vector (const __m128 &rhs)
 construct from SSE 128 byte float array
 
void load (const scalar *ptr)
 load content from 16-byte-aligned memory
 
void loadu (const scalar *ptr)
 load content from unaligned memory
 
void store (scalar *ptr) const
 write content to 16-byte-aligned memory through the write cache
 
void storeu (scalar *ptr) const
 write content to unaligned memory through the write cache
 
void operator= (const vector &rhs)
 assignment operator
 
void operator= (const __m128 &rhs)
 assign an vmVector4
 
void operator+= (const vector &rhs)
 inplace add
 
void operator-= (const vector &rhs)
 inplace sub
 
void operator*= (scalar s)
 inplace scalar multiply
 
bool operator== (const vector &rhs) const
 equality operator
 
bool operator!= (const vector &rhs) const
 inequality operator
 
float operator[] (int index) const
 
float & operator[] (int index)
 
 operator vec4 () const
 convert to vec4
 
 operator vec3 () const
 convert to vec3
 
void set (scalar x, scalar y, scalar z)
 set content
 

Static Public Member Functions

static vector nullvec ()
 create a null vector
 
static vector onevec ()
 create a 1,1,1 vector
 
static vector upvec ()
 create the up vector
 

Public Attributes

union { 
 
   __m128   vec 
 
   struct { 
 
      float   x 
 
      float   y 
 
      float   z 
 
   }  
 
};  
 

Constructor & Destructor Documentation

◆ vector() [1/7]

__forceinline Math::vector::vector ( )

default constructor

◆ vector() [2/7]

__forceinline Math::vector::vector ( scalar x,
scalar y,
scalar z )

construct from values

◆ vector() [3/7]

__forceinline Math::vector::vector ( scalar v)

construct from single value

◆ vector() [4/7]

__forceinline Math::vector::vector ( const vector & rhs)

copy constructor

◆ vector() [5/7]

__forceinline Math::vector::vector ( const vec3 & rhs)

construct from vec3

◆ vector() [6/7]

__forceinline Math::vector::vector ( const vec4 & rhs)

construct from vec4

◆ vector() [7/7]

__forceinline Math::vector::vector ( const __m128 & rhs)

construct from SSE 128 byte float array

Member Function Documentation

◆ load()

__forceinline void Math::vector::load ( const scalar * ptr)

load content from 16-byte-aligned memory

Load 4 floats from 16-byte-aligned memory.

◆ loadu()

__forceinline void Math::vector::loadu ( const scalar * ptr)

load content from unaligned memory

Load 4 floats from unaligned memory.

◆ nullvec()

__forceinline vector Math::vector::nullvec ( )
static

create a null vector

◆ onevec()

__forceinline vector Math::vector::onevec ( )
static

create a 1,1,1 vector

◆ operator vec3()

__forceinline Math::vector::operator vec3 ( ) const

convert to vec3

◆ operator vec4()

__forceinline Math::vector::operator vec4 ( ) const

convert to vec4

◆ operator!=()

__forceinline bool Math::vector::operator!= ( const vector & rhs) const

inequality operator

◆ operator*=()

__forceinline void Math::vector::operator*= ( scalar s)

inplace scalar multiply

◆ operator+=()

__forceinline void Math::vector::operator+= ( const vector & rhs)

inplace add

◆ operator-=()

__forceinline void Math::vector::operator-= ( const vector & rhs)

inplace sub

◆ operator=() [1/2]

__forceinline void Math::vector::operator= ( const __m128 & rhs)

assign an vmVector4

◆ operator=() [2/2]

__forceinline void Math::vector::operator= ( const vector & rhs)

assignment operator

◆ operator==()

__forceinline bool Math::vector::operator== ( const vector & rhs) const

equality operator

◆ operator[]() [1/2]

__forceinline float & Math::vector::operator[] ( int index)

◆ operator[]() [2/2]

__forceinline float Math::vector::operator[] ( int index) const

◆ set()

__forceinline void Math::vector::set ( scalar x,
scalar y,
scalar z )

set content

◆ store()

__forceinline void Math::vector::store ( scalar * ptr) const

write content to 16-byte-aligned memory through the write cache

Store to 16-byte-aligned float pointer.

◆ storeu()

__forceinline void Math::vector::storeu ( scalar * ptr) const

write content to unaligned memory through the write cache

Store to non-aligned float pointer.

◆ upvec()

__forceinline vector Math::vector::upvec ( )
static

create the up vector

Member Data Documentation

◆ [union]

union { ... } Math::vector

◆ vec

__m128 Math::vector::vec

◆ x

float Math::vector::x

◆ y

float Math::vector::y

◆ z

float Math::vector::z

The documentation for this struct was generated from the following file: