Module vec3

Source

Structs§

Vec3
A 3D vector with f64 components.

Functions§

cross
Computes the cross product of two vectors.
dot
Computes the dot product of two vectors.
random_in_hemisphere
Returns a random point in the hemisphere around the normal (uniform hemisphere sampling).
random_in_unit_disk
Returns a random point inside the unit disk (z=0 plane, rejection method).
random_in_unit_sphere
Returns a random point inside the unit sphere (rejection method).
random_unit_vector
Returns a random point on the unit sphere surface (true Lambertian reflection).
reflect
Computes the reflection vector (v: incident direction, n: unit surface normal).
refract
Computes the refraction vector (Snell’s law).
unit_vector
Returns the unit vector in the same direction as v.
write_color
Averages pixel_color over samples_per_pixel samples and converts to an “R G B” string.
write_color_gamma
Averages pixel_color over samples_per_pixel samples, applies gamma=2 correction (square root), and converts to an “R G B” string.

Type Aliases§

Color
Type alias for an RGB color (components in [0, 1]).
Point3
Type alias for a 3D point.