scimesh 0.3.2
Headless CPU-only 3D software renderer for scientific mesh visualization
Loading...
Searching...
No Matches
math_utils.h File Reference

Low-level math utilities for the rendering pipeline. More...

#include <scimesh/types.h>
#include <glm/gtc/matrix_transform.hpp>
#include <algorithm>
Include dependency graph for math_utils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  scimesh
 

Functions

Vec3 scimesh::compute_face_normal (const Vec3 &v0, const Vec3 &v1, const Vec3 &v2)
 Compute the unit-length normal vector of a triangle face.
 
Vec3 scimesh::transform_point (const Mat4 &m, const Vec3 &p)
 Transform a point by a 4×4 matrix (with implicit w=1).
 
Vec4 scimesh::transform_point_homogeneous (const Mat4 &m, const Vec3 &p)
 Transform a point by a 4×4 matrix, returning the full Vec4 result.
 
Vec3 scimesh::transform_direction (const Mat4 &m, const Vec3 &d)
 Transform a direction vector by a 4×4 matrix (with implicit w=0).
 
Vec3 scimesh::perspective_divide (const Vec4 &clip)
 Perform perspective division: divide xyz by w.
 
void scimesh::ndc_to_screen (const Vec3 &ndc, int width, int height, float &screen_x, float &screen_y, float &depth)
 Convert from normalized device coordinates (NDC) to screen (pixel) coordinates.
 
void scimesh::compute_barycentric (float px, float py, float x0, float y0, float x1, float y1, float x2, float y2, float &u, float &v, float &w)
 Compute barycentric coordinates (u, v, w) of a point in a triangle.
 
Color scimesh::shade_pixel (const Color &base_color, const Vec3 &normal, const Vec3 &light_direction, const Color &specular_color=Color(0, 0, 0, 0), float shininess=0.0f)
 Compute the shaded color of a pixel with a single directional light.
 
Color scimesh::shade_pixel_multi (const Color &base_color, const Vec3 &normal, const std::vector< Light > &lights, float ambient, const Color &specular_color=Color(0, 0, 0, 0), float shininess=0.0f)
 Compute the shaded color with multiple light sources.
 

Detailed Description

Low-level math utilities for the rendering pipeline.

These are inline helper functions used throughout the rasterizer and pipeline. Most users won't call these directly, but they can be useful for custom rendering or debugging.

Definition in file math_utils.h.