Defines | Typedefs | Functions

include/Vector3D.h File Reference

This file is the main header for 3d vector operations. More...

#include <math.h>
#include <immintrin.h>
#include "Vector3D.hpp"

Go to the source code of this file.

Defines

#define VECTOR3D_DOTP_MASK   0x71
#define VECTOR3D_ROT1_MASK   0xC9
#define VECTOR3D_ROT2_MASK   0xD2

Typedefs

typedef align16 __m128 Vector3D__
struct {
   float   x
   float   y
   float   z
   float   _
Vector3D_v
struct {
   float   r
   float   phi
   float   z
   float   _
Vector3D_c
struct {
   float   r
   float   phi
   float   theta
   float   _
Vector3D_s
union {
   align16 Vector3D__   _
   align16 Vector3D_v   v
   align16 Vector3D_c   c
   align16 Vector3D_s   s
Vector3D_t

Functions

__forceinline Vector3D_t Vector3D ()
 vector zero initializer
__forceinline Vector3D_t Vector3D (register float S0)
 vector float initializer
__forceinline Vector3D_t Vector3D (register float x, register float y, register float z)
 cartesian vector initializer
__forceinline Vector3D_t Vector3DC (register float r, register float phi, register float z)
 cylindrical vector initializer
__forceinline Vector3D_t Vector3DS (register float r, register float phi, register float theta)
 spherical vector initializer
__forceinline Vector3D_t add (register Vector3D_t L0, register Vector3D_t R0)
 vector addition
__forceinline void add_ (register Vector3D_t &L0, register Vector3D_t R0)
 vector addition-assignment (L0 += R0)
__forceinline Vector3D_t sub (register Vector3D_t L0, register Vector3D_t R0)
 vector subtraction
__forceinline void sub_ (register Vector3D_t &L0, register Vector3D_t R0)
 vector subtraction-assignment (L0 -= R0)
__forceinline Vector3D_t mul (register Vector3D_t L0, register float R0)
 scalar vector multiplication
__forceinline void mul_ (register Vector3D_t &L0, register float R0)
 scalar vector multiplication-assignment (L0 *= R0)
__forceinline Vector3D_t div (register Vector3D_t L0, register float R0)
 scalar vector division
__forceinline void div_ (register Vector3D_t &L0, register float R0)
 scalar vector division-assignment (L0 /= R0)
__forceinline float dot (register Vector3D_t L0, register Vector3D_t R0)
 the cartesian dot (or scalar) product resp. the inner product of the euclidean vector space
__forceinline Vector3D_t cross (register Vector3D_t L0, register Vector3D_t R0)
 the cartesian cross product
__forceinline void cross_ (register Vector3D_t &L0, register Vector3D_t R0)
 the self-assigning cartesian cross product (L0 x= R0)
__forceinline float triple (register Vector3D_t L0, register Vector3D_t M0, register Vector3D_t R0)
 the cartesian vector-valued vector triple product
__forceinline float abs (register Vector3D_t V0)
 the cartesian absolute value resp. length of a vector
__forceinline float absC (register Vector3D_t V0)
 the cylindrical absolute value resp. length of a vector
__forceinline float absS (register Vector3D_t V0)
 the spherical absolute value resp. length of a vector
__forceinline Vector3D_t unit (register Vector3D_t V0)
 the cartesian unit vector
__forceinline void unit_ (register Vector3D_t &V0)
 self-assign the cartesian unit vector: V0 /= abs(V0)
__forceinline Vector3D_t unitC (register Vector3D_t V0)
 the cylindrical unit vector
__forceinline void unitC_ (register Vector3D_t &V0)
 self-assign the cylindrical unit vector: V0 = ( V0.c.r/abs(V0) , 0.0f , V0.c.z/abs(V0) )
__forceinline Vector3D_t unitS (register Vector3D_t V0)
 the sherical unit vector
__forceinline void unitS_ (register Vector3D_t &V0)
 self-assign the spherical unit vector: V0 = ( 1.0f , V0.s.phi , V0.s.theta )
__forceinline Vector3D_t v2c (register Vector3D_t V0)
 convert cartesian coordinates to cylindrical coordinates
__forceinline void v2c_ (register Vector3D_t &V0)
 convert cartesian coordinates to cylindrical coordinates (self-assigned)
__forceinline Vector3D_t v2s (register Vector3D_t V0)
 convert cartesian coordinates to spherical coordinates
__forceinline void v2s_ (register Vector3D_t &V0)
 convert cartesian coordinates to spherical coordinates (self-assigned)
__forceinline Vector3D_t c2v (register Vector3D_t V0)
 convert cylindrical coordinates to cartesian coordinates
__forceinline void c2v_ (register Vector3D_t &V0)
 convert cylindrical coordinates to cartesian coordinates (self-assigned)
__forceinline Vector3D_t c2s (register Vector3D_t V0)
 convert cylindrical coordinates to spherical coordinates
__forceinline void c2s_ (register Vector3D_t &V0)
 convert cylindrical coordinates to spherical coordinates (self-assigned)
__forceinline Vector3D_t s2v (register Vector3D_t V0)
 convert spherical coordinates to cartesian coordinates
__forceinline void s2v_ (register Vector3D_t &V0)
 convert spherical coordinates to cartesian coordinates (self-assigned)
__forceinline Vector3D_t s2c (register Vector3D_t V0)
 convert spherical coordinates to cylindrical coordinates
__forceinline void s2c_ (register Vector3D_t &V0)
 convert spherical coordinates to cylindrical coordinates (self-assigned)

Detailed Description

This file is the main header for 3d vector operations.

Version:
0.1b
Author:
Hans-Christian Ahlswede

This file is the header which defines data types and declares functions for 3d vector operations such as addition/subtraction, multiplication/division dot/cross/triple-product, absolute values, normalization and angular functions.

Warning:
using the compiler flags -O1 and sse-intrinsics results in slower code, choose -Os or at least -O2 if sse is enabled.

Function Documentation

__forceinline float abs ( register Vector3D_t  V0 )

the cartesian absolute value resp. length of a vector

Parameters:
V0the vector in cartesian coordinates
Returns:
the (scalar) value: sqrt(<V0,V0>) resp. sqrt(V0.V0)
__forceinline float absC ( register Vector3D_t  V0 )

the cylindrical absolute value resp. length of a vector

Parameters:
V0the vector in cylindrical coordinates
Returns:
the (scalar) value: sqrt(V0.c.r^2 + V0.c.z^2)
Warning:
not yet implemented
__forceinline float absS ( register Vector3D_t  V0 )

the spherical absolute value resp. length of a vector

Parameters:
V0the vector in spherical coordinates
Returns:
the (scalar) value: V0.s.r
Warning:
not yet implemented
__forceinline Vector3D_t add ( register Vector3D_t  L0,
register Vector3D_t  R0 
)

vector addition

Parameters:
L0the left hand sided operand
R0the right hand sided operand
Returns:
the sum vector: L0 + R0
__forceinline void add_ ( register Vector3D_t &  L0,
register Vector3D_t  R0 
)

vector addition-assignment (L0 += R0)

Parameters:
L0the left hand sided operand, this parameter will also hold the result
R0the right hand sided operand
__forceinline Vector3D_t c2s ( register Vector3D_t  V0 )

convert cylindrical coordinates to spherical coordinates

Parameters:
V0the vector in cylindrical coordinates
Returns:
the vector in spherical coordinates
Warning:
not yet implemented
__forceinline void c2s_ ( register Vector3D_t &  V0 )

convert cylindrical coordinates to spherical coordinates (self-assigned)

Parameters:
V0the vector in cylindrical coordinates
Warning:
not yet implemented
__forceinline Vector3D_t c2v ( register Vector3D_t  V0 )

convert cylindrical coordinates to cartesian coordinates

Parameters:
V0the vector in cylindrical coordinates
Returns:
the vector in cartesian coordinates
Warning:
not yet implemented
__forceinline void c2v_ ( register Vector3D_t &  V0 )

convert cylindrical coordinates to cartesian coordinates (self-assigned)

Parameters:
V0the vector in cylindrical coordinates
Warning:
not yet implemented
__forceinline Vector3D_t cross ( register Vector3D_t  L0,
register Vector3D_t  R0 
)

the cartesian cross product

Parameters:
L0the left hand sided (vector) operand in cartesian coordinates
R0the right hand sided (vector) operand in cartesian coordinates
Returns:
the vector: L0 x R0
__forceinline void cross_ ( register Vector3D_t &  L0,
register Vector3D_t  R0 
)

the self-assigning cartesian cross product (L0 x= R0)

Parameters:
L0the left hand sided (vector) operand in cartesian coordinates, this parameter will also hold the result
R0the right hand sided (vector) operand in cartesian coordinates
__forceinline Vector3D_t div ( register Vector3D_t  L0,
register float  R0 
)

scalar vector division

Parameters:
L0the left hand sided (vector) operand
R0the right hand sided (scalar) operand
Returns:
the scalar divided vector: L0*R0
__forceinline void div_ ( register Vector3D_t &  L0,
register float  R0 
)

scalar vector division-assignment (L0 /= R0)

Parameters:
L0the left hand sided (vector) operand, this parameter will also hold the result
R0the right hand sided (scalar) operand
__forceinline float dot ( register Vector3D_t  L0,
register Vector3D_t  R0 
)

the cartesian dot (or scalar) product resp. the inner product of the euclidean vector space

Parameters:
L0the left hand sided (vector) operand in cartesian coordinates
R0the right hand sided (vector) operand in cartesian coordinates
Returns:
the (scalar) value: L0.R0 resp. <L0,R0>
__forceinline Vector3D_t mul ( register Vector3D_t  L0,
register float  R0 
)

scalar vector multiplication

Parameters:
L0the left hand sided (vector) operand
R0the right hand sided (scalar) operand
Returns:
the scalar multiplied vector: L0*R0
__forceinline void mul_ ( register Vector3D_t &  L0,
register float  R0 
)

scalar vector multiplication-assignment (L0 *= R0)

Parameters:
L0the left hand sided (vector) operand, this parameter will also hold the result
R0the right hand sided (scalar) operand
__forceinline Vector3D_t s2c ( register Vector3D_t  V0 )

convert spherical coordinates to cylindrical coordinates

Parameters:
V0the vector in spherical coordinates
Returns:
the vector in cylindrical coordinates
Warning:
not yet implemented
__forceinline void s2c_ ( register Vector3D_t &  V0 )

convert spherical coordinates to cylindrical coordinates (self-assigned)

Parameters:
V0the vector in spherical coordinates
Warning:
not yet implemented
__forceinline Vector3D_t s2v ( register Vector3D_t  V0 )

convert spherical coordinates to cartesian coordinates

Parameters:
V0the vector in spherical coordinates
Returns:
the vector in cartesian coordinates
Warning:
not yet implemented
__forceinline void s2v_ ( register Vector3D_t &  V0 )

convert spherical coordinates to cartesian coordinates (self-assigned)

Parameters:
V0the vector in spherical coordinates
Warning:
not yet implemented
__forceinline Vector3D_t sub ( register Vector3D_t  L0,
register Vector3D_t  R0 
)

vector subtraction

Parameters:
L0the left hand sided operand
R0the right hand sided operand
Returns:
the difference vector: L0 - R0
__forceinline void sub_ ( register Vector3D_t &  L0,
register Vector3D_t  R0 
)

vector subtraction-assignment (L0 -= R0)

Parameters:
L0the left hand sided operand, this parameter will also hold the result
R0the right hand sided operand
__forceinline float triple ( register Vector3D_t  L0,
register Vector3D_t  M0,
register Vector3D_t  R0 
)

the cartesian vector-valued vector triple product

Parameters:
L0the left hand sided (vector) operand in cartesian coordinates
M0the middle (vector) operand in cartesian coordinates
R0the right hand sided (vector) operand in cartesian coordinates
Returns:
the vector: [L0,M0,R0] resp. <L0,M0 x R0> resp. L0.(M0 x R0)
__forceinline Vector3D_t unit ( register Vector3D_t  V0 )

the cartesian unit vector

Parameters:
V0the vector
Returns:
the unit vector: V0 / abs(V0)
__forceinline void unit_ ( register Vector3D_t &  V0 )

self-assign the cartesian unit vector: V0 /= abs(V0)

Parameters:
V0the vector
__forceinline Vector3D_t unitC ( register Vector3D_t  V0 )

the cylindrical unit vector

Parameters:
V0the vector
Returns:
the unit vector: ( V0.c.r/abs(V0) , 0.0f , V0.c.z/abs(V0) )
Warning:
not yet implemented
__forceinline void unitC_ ( register Vector3D_t &  V0 )

self-assign the cylindrical unit vector: V0 = ( V0.c.r/abs(V0) , 0.0f , V0.c.z/abs(V0) )

Parameters:
V0the vector
Warning:
not yet implemented
__forceinline Vector3D_t unitS ( register Vector3D_t  V0 )

the sherical unit vector

Parameters:
V0the vector
Returns:
the unit vector: ( 1.0f , V0.s.phi , V0.s.theta )
Warning:
not yet implemented
__forceinline void unitS_ ( register Vector3D_t &  V0 )

self-assign the spherical unit vector: V0 = ( 1.0f , V0.s.phi , V0.s.theta )

Parameters:
V0the vector
Warning:
not yet implemented
__forceinline Vector3D_t v2c ( register Vector3D_t  V0 )

convert cartesian coordinates to cylindrical coordinates

Parameters:
V0the vector in cartesian coordinates
Returns:
the vector in cylindrical coordinates
Warning:
not yet implemented
__forceinline void v2c_ ( register Vector3D_t &  V0 )

convert cartesian coordinates to cylindrical coordinates (self-assigned)

Parameters:
V0the vector in cartesian coordinates
Warning:
not yet implemented
__forceinline Vector3D_t v2s ( register Vector3D_t  V0 )

convert cartesian coordinates to spherical coordinates

Parameters:
V0the vector in cartesian coordinates
Returns:
the vector in spherical coordinates
Warning:
not yet implemented
__forceinline void v2s_ ( register Vector3D_t &  V0 )

convert cartesian coordinates to spherical coordinates (self-assigned)

Parameters:
V0the vector in cartesian coordinates
Warning:
not yet implemented
__forceinline Vector3D_t Vector3D ( register float  x,
register float  y,
register float  z 
)

cartesian vector initializer

Parameters:
xinitialization value for the x coordinate
yinitialization value for the y coordinate
zinitialization value for the z coordinate
Returns:
a cartesian vector where the element are initialized to the parameters x, y and z
__forceinline Vector3D_t Vector3D (  )

vector zero initializer

Returns:
a vector where each element is initialized to 0.0f
__forceinline Vector3D_t Vector3D ( register float  S0 )

vector float initializer

Parameters:
S0initialization value
Returns:
a vector where each element is initialized to parameter S0
__forceinline Vector3D_t Vector3DC ( register float  r,
register float  phi,
register float  z 
)

cylindrical vector initializer

Parameters:
rinitialization value for the r coordinate (radial coordinate)
phiinitialization value for the phi coordinate (polar coordinate)
zinitialization value for the z coordinate
Returns:
a cylindrical vector where the element are initialized to the parameters r, pi and z
Warning:
not yet implemented
__forceinline Vector3D_t Vector3DS ( register float  r,
register float  phi,
register float  theta 
)

spherical vector initializer

Parameters:
rinitialization value for the r coordinate (radial coordinate)
phiinitialization value for the phi coordinate (polar coordinate)
thetainitialization value for the theta coordinate (azimuthal coordinate)
Returns:
a spherical vector where the element are initialized to the parameters r, phi and theta
Warning:
not yet implemented
 All Files Functions