~turminal/raytracing

3743a74c6e4ae1a1f54f9be1296639f9dab2502b — Bor Grošelj Simić 2 years ago cc772aa
implement cross product
1 files changed, 6 insertions(+), 0 deletions(-)

M vector.ha
M vector.ha => vector.ha +6 -0
@@ 26,6 26,12 @@ export fn sum(v1: vector, v2: vector) vector = vector {

export fn diff(v1: vector, v2: vector) vector = sum(v1, neg(v2));

export fn cross(v1: vector, v2: vector) vector = vector {
	x = v1.y * v2.z - v1.z * v2.y,
	y = v1.z * v2.x - v1.x * v2.z,
	z = v1.x * v2.y - v1.y * v2.x,
};

export fn dot(v1: vector, v2: vector) f64 = v1.x * v2.x + v1.y * v2.y + v1.z * v2.z;

export fn length(v: vector) f64 = math::sqrtf64(dot(v, v));