From 34f3001c0ae2ac20ad02f02434a2e13c50c8b6d8 Mon Sep 17 00:00:00 2001 From: yum Date: Wed, 8 Apr 2026 22:16:35 -0700 Subject: add rotation to c31 hexagons needs some cleanup but it's pretty efficient, at least --- math.cginc | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'math.cginc') diff --git a/math.cginc b/math.cginc index 15d02eb..ee70495 100755 --- a/math.cginc +++ b/math.cginc @@ -67,6 +67,12 @@ float3 rotate_vector(float3 v, float4 q) return v + q.w * t + cross(q.xyz, t); } +float4 get_quaternion(float3 axis_normal, float theta) { + float sint2, cost2; + sincos(theta*0.5, sint2, cost2); + return float4(axis_normal * sint2, cost2); +} + // Cartesian to packed cube hexagonal coordinates. // Stores (q + r, q, r), where the article's cube coordinates satisfy // q + r + s = 0 and s = -(q + r). -- cgit v1.2.3