srp
software rendering pipeline
Loading...
Searching...
No Matches
vec.h File Reference
#include <stdint.h>
Include dependency graph for vec.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

union  vec2
 
union  vec3
 
union  vec4
 
#define VEC2(x, y)   ((vec2) {{x, y}})
 
#define VEC3(x, y, z)   ((vec3) {{x, y, z}})
 
#define VEC4(x, y, z, w)   ((vec4) {{x, y, z, w}})
 
#define VEC4_FROM_VEC3(v, a)   ((vec4) {.xyz = (v), .___w = (a)})
 
#define SWZ2(v, a, b)   ((vec2) {{(v).a, (v).b}})
 
#define SWZ3(v, a, b, c)   ((vec3) {{(v).a, (v).b, (v).c}})
 
#define SWZ4(v, a, b, c, d)   ((vec4) {{(v).a, (v).b, (v).c, (v).d}})
 
typedef union vec2 vec2
 
typedef union vec3 vec3
 
typedef union vec4 vec4
 
vec2 vec2Add (vec2 a, vec2 b)
 
vec2 vec2Subtract (vec2 a, vec2 b)
 
float vec2DotProduct (vec2 a, vec2 b)
 
vec2 vec2MultiplyScalar (vec2 a, float b)
 
vec2 vec2Normalize (vec2 v)
 
vec2 vec2Reflect (vec2 i, vec2 n)
 
vec2 vec2MultiplyVec2 (vec2 a, vec2 b)
 
vec2 vec2Negate (vec2 v)
 
vec3 vec3Add (vec3 a, vec3 b)
 
vec3 vec3Subtract (vec3 a, vec3 b)
 
float vec3DotProduct (vec3 a, vec3 b)
 
vec3 vec3MultiplyScalar (vec3 a, float b)
 
vec3 vec3Normalize (vec3 v)
 
vec3 vec3Reflect (vec3 i, vec3 n)
 
vec3 vec3MultiplyVec3 (vec3 a, vec3 b)
 
vec3 vec3Negate (vec3 v)
 
vec4 vec4Add (vec4 a, vec4 b)
 
vec4 vec4Subtract (vec4 a, vec4 b)
 
float vec4DotProduct (vec4 a, vec4 b)
 
vec4 vec4MultiplyScalar (vec4 a, float b)
 
vec4 vec4Normalize (vec4 v)
 
vec4 vec4Reflect (vec4 i, vec4 n)
 
vec4 vec4MultiplyVec4 (vec4 a, vec4 b)
 
vec4 vec4Negate (vec4 v)
 

Detailed Description

vec2, vec3, vec4 definition

Macro Definition Documentation

◆ SWZ2

#define SWZ2 (   v,
  a,
 
)    ((vec2) {{(v).a, (v).b}})

Swizzle macros

◆ VEC2

#define VEC2 (   x,
 
)    ((vec2) {{x, y}})

Instantiation macros

Typedef Documentation

◆ vec3

typedef union vec3 vec3

Represents a 3-element vector of floats

◆ vec4

typedef union vec4 vec4

Represents a 4-element vector of floats

Function Documentation

◆ vec2DotProduct()

float vec2DotProduct ( vec2  a,
vec2  b 
)

Calculate the dot product of two vectors

◆ vec2MultiplyScalar()

vec2 vec2MultiplyScalar ( vec2  a,
float  b 
)

Multiply a vector with a scalar value

◆ vec2MultiplyVec2()

vec2 vec2MultiplyVec2 ( vec2  a,
vec2  b 
)

Component-wise multiplication (Hadamard product)

◆ vec2Negate()

vec2 vec2Negate ( vec2  v)

Negate all components of a vector

◆ vec2Normalize()

vec2 vec2Normalize ( vec2  v)

Normalize a vector to have a length of 1

◆ vec2Reflect()

vec2 vec2Reflect ( vec2  i,
vec2  n 
)

Reflect an incident vector I against a surface normal N

◆ vec2Subtract()

vec2 vec2Subtract ( vec2  a,
vec2  b 
)

Subtract two vectors

◆ vec3Add()

vec3 vec3Add ( vec3  a,
vec3  b 
)

Add two vectors

◆ vec3DotProduct()

float vec3DotProduct ( vec3  a,
vec3  b 
)

Calculate the dot product of two vectors

◆ vec3MultiplyScalar()

vec3 vec3MultiplyScalar ( vec3  a,
float  b 
)

Multiply a vector with a scalar value

◆ vec3MultiplyVec3()

vec3 vec3MultiplyVec3 ( vec3  a,
vec3  b 
)

Component-wise multiplication (Hadamard product)

◆ vec3Negate()

vec3 vec3Negate ( vec3  v)

Negate all components of a vector

◆ vec3Normalize()

vec3 vec3Normalize ( vec3  v)

Normalize a vector to have a length of 1

◆ vec3Reflect()

vec3 vec3Reflect ( vec3  i,
vec3  n 
)

Reflect an incident vector I against a surface normal N

◆ vec3Subtract()

vec3 vec3Subtract ( vec3  a,
vec3  b 
)

Subtract two vectors

◆ vec4Add()

vec4 vec4Add ( vec4  a,
vec4  b 
)

Add two vectors

◆ vec4DotProduct()

float vec4DotProduct ( vec4  a,
vec4  b 
)

Calculate the dot product of two vectors

◆ vec4MultiplyScalar()

vec4 vec4MultiplyScalar ( vec4  a,
float  b 
)

Multiply a vector with a scalar value

◆ vec4MultiplyVec4()

vec4 vec4MultiplyVec4 ( vec4  a,
vec4  b 
)

Component-wise multiplication (Hadamard product)

◆ vec4Negate()

vec4 vec4Negate ( vec4  v)

Negate all components of a vector

◆ vec4Normalize()

vec4 vec4Normalize ( vec4  v)

Normalize a vector to have a length of 1

◆ vec4Reflect()

vec4 vec4Reflect ( vec4  i,
vec4  n 
)

Reflect an incident vector I against a surface normal N

◆ vec4Subtract()

vec4 vec4Subtract ( vec4  a,
vec4  b 
)

Subtract two vectors