From b938ef85e0083ad63c0a2effa71503e005f47bd0 Mon Sep 17 00:00:00 2001 From: Lars Mueller Date: Fri, 9 Sep 2022 14:34:42 +0200 Subject: [PATCH] Add vector.reflect --- vector.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vector.lua b/vector.lua index 3e94145..e37368e 100644 --- a/vector.lua +++ b/vector.lua @@ -187,6 +187,10 @@ function dot(v, w) return sum end +function reflect(v, normal --[[**normalized** plane normal vector]]) + return subtract(v, multiply_scalar(normal, 2 * dot(v, normal))) -- reflection of v at the plane +end + --+ Angle between two vectors --> Signed angle in radians function angle(v, w)