5. Boost package for math
The math boost module implements collection of helper macros and functions to accompany math.
All functions and symbols are in “math_boost” module, use require to get access to it.
require daslib/math_boost
- AABR
AABR fields are
| min | float2 | 
| max | float2 | 
axis aligned bounding rectangle
- AABB
AABB fields are
| min | float3 | 
| max | float3 | 
axis aligned bounding box
- Ray
Ray fields are
| dir | float3 | 
| origin | float3 | 
ray (direction and origin)
5.1. Angle conversions
- degrees(f: float const)
degrees returns float const
| argument | argument type | 
|---|---|
| f | float const | 
convert radians to degrees
- radians(f: float const)
radians returns float const
| argument | argument type | 
|---|---|
| f | float const | 
convert degrees to radians
5.2. Intersections
- is_intersecting(a: AABR const; b: AABR const)
is_intersecting returns bool const
| argument | argument type | 
|---|---|
| a | math_boost::AABR const | 
| b | math_boost::AABR const | 
A.LO<=B.HI && A.HI>=B.LO
- is_intersecting(a: AABB const; b: AABB const)
is_intersecting returns bool const
| argument | argument type | 
|---|---|
| a | math_boost::AABB const | 
| b | math_boost::AABB const | 
A.LO<=B.HI && A.HI>=B.LO
- is_intersecting(ray: Ray const; aabb: AABB const; Tmin: float const; Tmax: float const)
is_intersecting returns bool const
| argument | argument type | 
|---|---|
| ray | math_boost::Ray const | 
| aabb | math_boost::AABB const | 
| Tmin | float const | 
| Tmax | float const | 
A.LO<=B.HI && A.HI>=B.LO
5.3. Matrices
look_at_lh (Eye:float3 const;At:float3 const;Up:float3 const) : math::float4x4
look_at_rh (Eye:float3 const;At:float3 const;Up:float3 const) : math::float4x4
perspective_lh (fovy:float const;aspect:float const;zn:float const;zf:float const) : math::float4x4
perspective_rh (fovy:float const;aspect:float const;zn:float const;zf:float const) : math::float4x4
planar_shadow (Light:float4 const;Plane:float4 const) : math::float4x4
- look_at_lh(Eye: float3 const; At: float3 const; Up: float3 const)
look_at_lh returns math::float4x4
| argument | argument type | 
|---|---|
| Eye | float3 const | 
| At | float3 const | 
| Up | float3 const | 
left-handed (z forward) look at matrix with origin at Eye and target at At, and up vector Up.
- look_at_rh(Eye: float3 const; At: float3 const; Up: float3 const)
look_at_rh returns math::float4x4
| argument | argument type | 
|---|---|
| Eye | float3 const | 
| At | float3 const | 
| Up | float3 const | 
right-handed (z towards viewer) look at matrix with origin at Eye and target at At, and up vector Up.
- perspective_lh(fovy: float const; aspect: float const; zn: float const; zf: float const)
perspective_lh returns math::float4x4
| argument | argument type | 
|---|---|
| fovy | float const | 
| aspect | float const | 
| zn | float const | 
| zf | float const | 
left-handed (z forward) perspective matrix
- perspective_rh(fovy: float const; aspect: float const; zn: float const; zf: float const)
perspective_rh returns math::float4x4
| argument | argument type | 
|---|---|
| fovy | float const | 
| aspect | float const | 
| zn | float const | 
| zf | float const | 
right-handed (z toward viewer) perspective matrix
- perspective_rh_opengl(fovy: float const; aspect: float const; zn: float const; zf: float const)
perspective_rh_opengl returns math::float4x4
| argument | argument type | 
|---|---|
| fovy | float const | 
| aspect | float const | 
| zn | float const | 
| zf | float const | 
right-handed (z toward viewer) opengl (z in [-1..1]) perspective matrix
- ortho_rh(left: float const; right: float const; bottom: float const; top: float const; zNear: float const; zFar: float const)
ortho_rh returns math::float4x4
| argument | argument type | 
|---|---|
| left | float const | 
| right | float const | 
| bottom | float const | 
| top | float const | 
| zNear | float const | 
| zFar | float const | 
right handed (z towards viwer) orthographic (parallel) projection matrix
- planar_shadow(Light: float4 const; Plane: float4 const)
planar_shadow returns math::float4x4
| argument | argument type | 
|---|---|
| Light | float4 const | 
| Plane | float4 const | 
planar shadow projection matrix, i.e. all light shadows to be projected on a plane
5.4. Plane
- plane_dot(Plane: float4 const; Vec: float4 const)
plane_dot returns float const
| argument | argument type | 
|---|---|
| Plane | float4 const | 
| Vec | float4 const | 
dot product of Plane and ‘Vec’
- plane_normalize(Plane: float4 const)
plane_normalize returns float4 const
| argument | argument type | 
|---|---|
| Plane | float4 const | 
normalize `Plane’, length xyz will be 1.0 (or 0.0 for no plane)
- plane_from_point_normal(p: float3 const; n: float3 const)
plane_from_point_normal returns float4 const
| argument | argument type | 
|---|---|
| p | float3 const | 
| n | float3 const | 
construct plane from point p and normal n
5.5. Color packig and unpacking
- RGBA_TO_UCOLOR(x: float const; y: float const; z: float const; w: float const)
RGBA_TO_UCOLOR returns uint const
| argument | argument type | 
|---|---|
| x | float const | 
| y | float const | 
| z | float const | 
| w | float const | 
conversion from RGBA to ucolor. x,y,z,w are in [0,1] range
- RGBA_TO_UCOLOR(xyzw: float4 const)
RGBA_TO_UCOLOR returns uint const
| argument | argument type | 
|---|---|
| xyzw | float4 const | 
conversion from RGBA to ucolor. x,y,z,w are in [0,1] range
- UCOLOR_TO_RGBA(x: uint const)
UCOLOR_TO_RGBA returns float4 const
| argument | argument type | 
|---|---|
| x | uint const | 
conversion from ucolor to RGBA. x components are in [0,255] range
- UCOLOR_TO_RGB(x: uint const)
UCOLOR_TO_RGB returns float3 const
| argument | argument type | 
|---|---|
| x | uint const | 
conversion from ucolor to RGB. x components are in [0,255] range. result is float3(x,y,z)
5.6. Uncategorized
- linear_to_SRGB(x: float const)
linear_to_SRGB returns float const
| argument | argument type | 
|---|---|
| x | float const | 
convert value from linear space to sRGB curve space
- linear_to_SRGB(c: float3 const)
linear_to_SRGB returns float3 const
| argument | argument type | 
|---|---|
| c | float3 const | 
convert value from linear space to sRGB curve space
- linear_to_SRGB(c: float4 const)
linear_to_SRGB returns float4 const
| argument | argument type | 
|---|---|
| c | float4 const | 
convert value from linear space to sRGB curve space