KiCad PCB EDA Suite
Loading...
Searching...
No Matches
3d_math.h File Reference

Defines math related functions. More...

Go to the source code of this file.

Functions

SFVEC3F SphericalToCartesian (float aInclination, float aAzimuth)
 https://en.wikipedia.org/wiki/Spherical_coordinate_system More...
 
SFVEC3F UniformRandomHemisphereDirection ()
 
SFVEC3F CosWeightedRandomHemisphereDirection (const SFVEC3F &n)
 
bool Refract (const SFVEC3F &aInVector, const SFVEC3F &aNormal, float aRin_over_Rout, SFVEC3F &aOutVector)
 Based on: https://github.com/mmp/pbrt-v3/blob/master/src/core/reflection.h See also: http://www.flipcode.com/archives/Raytracing_Topics_Techniques-Part_3_Refractions_and_Beers_Law.shtml. More...
 
float mapf (float x, float in_min, float in_max, float out_min, float out_max)
 
float RGBtoGray (const SFVEC3F &aColor)
 
SFVEC3F MaterialDiffuseToColorCAD (const SFVEC3F &aDiffuseColor)
 
float QuadricEasingInOut (float t)
 
float BezierBlend (float t)
 

Detailed Description

Defines math related functions.

Definition in file 3d_math.h.

Function Documentation

◆ BezierBlend()

float BezierBlend ( float  t)
inline

Definition at line 179 of file 3d_math.h.

Referenced by TRACK_BALL::Interpolate().

◆ CosWeightedRandomHemisphereDirection()

SFVEC3F CosWeightedRandomHemisphereDirection ( const SFVEC3F n)
inline

Definition at line 69 of file 3d_math.h.

◆ mapf()

float mapf ( float  x,
float  in_min,
float  in_max,
float  out_min,
float  out_max 
)
inline

Definition at line 133 of file 3d_math.h.

Referenced by RENDER_3D_OPENGL::setupMaterials().

◆ MaterialDiffuseToColorCAD()

SFVEC3F MaterialDiffuseToColorCAD ( const SFVEC3F aDiffuseColor)
inline

Definition at line 147 of file 3d_math.h.

References RGBtoGray().

Referenced by RENDER_3D_RAYTRACE::addModels(), MODEL_3D::Draw(), and MODEL_3D::MODEL_3D().

◆ QuadricEasingInOut()

float QuadricEasingInOut ( float  t)
inline

Definition at line 163 of file 3d_math.h.

Referenced by TRACK_BALL::Interpolate().

◆ Refract()

bool Refract ( const SFVEC3F aInVector,
const SFVEC3F aNormal,
float  aRin_over_Rout,
SFVEC3F aOutVector 
)
inline

Based on: https://github.com/mmp/pbrt-v3/blob/master/src/core/reflection.h See also: http://www.flipcode.com/archives/Raytracing_Topics_Techniques-Part_3_Refractions_and_Beers_Law.shtml.

Parameters
aInVectorincoming vector.
aNormalnormal in the intersection point.
aRin_over_Routincoming refraction index / out refraction index.
aOutVectorthe refracted vector.
Returns
true

Definition at line 112 of file 3d_math.h.

Referenced by RENDER_3D_RAYTRACE::shadeHit().

◆ RGBtoGray()

float RGBtoGray ( const SFVEC3F aColor)
inline

Definition at line 140 of file 3d_math.h.

Referenced by RENDER_3D_RAYTRACE::getModelMaterial(), and MaterialDiffuseToColorCAD().

◆ SphericalToCartesian()

SFVEC3F SphericalToCartesian ( float  aInclination,
float  aAzimuth 
)
inline

https://en.wikipedia.org/wiki/Spherical_coordinate_system

Parameters
aInclinationθ ∈ [0, π]
aAzimuthφ ∈ [0, 2π]
Returns
Cartesian coordinates

Definition at line 43 of file 3d_math.h.

Referenced by init_lights(), and RENDER_3D_RAYTRACE::Reload().

◆ UniformRandomHemisphereDirection()

SFVEC3F UniformRandomHemisphereDirection ( )
inline
Todo:
This is not correct because it is not a gaussian random.

Definition at line 55 of file 3d_math.h.

References Fast_RandFloat().

Referenced by RENDER_3D_RAYTRACE::shadeHit().