Skip to content

Instantly share code, notes, and snippets.

Avatar

Jarkko Lempiainen JarkkoPFC

View GitHub Profile
@JarkkoPFC
JarkkoPFC / cone_vector.h
Last active Feb 4, 2020
Calculate 3D unit vectors in a cone for MC-integration
View cone_vector.h
struct vec2f {float x, y;};
struct vec3f {float x, y, z;};
//============================================================================
// cone_uniform_vector
//============================================================================
// Returns uniformly distributed unit vector on a [0, 0, 1] oriented cone of
// given apex angle and uniform random vector xi ([x, y] in range [0, 1]).
// e.g. cos_half_apex_angle = 0 returns samples on a hemisphere (cos(pi/2)=0),
// while cos_half_apex_angle = -1 returns samples on a sphere (cos(pi)=-1)
@JarkkoPFC
JarkkoPFC / sphere_screen_extents.h
Last active May 17, 2020
Calculates view space 3D sphere extents on the screen
View sphere_screen_extents.h
struct vec3f {float x, y, z;};
struct vec4f {float x, y, z, w;};
struct mat44f {vec4f x, y, z, w;};
//============================================================================
// sphere_screen_extents
//============================================================================
// Calculates the exact screen extents xyzw=[left, bottom, right, top] in
// normalized screen coordinates [-1, 1] for a sphere in view space. For
// performance, the projection matrix (v2p) is assumed to be setup so that
You can’t perform that action at this time.