From af53f189e85b8ee47e504eb1237d5e813a2d051b Mon Sep 17 00:00:00 2001 From: Don Cross Date: Thu, 26 Oct 2023 10:37:13 -0400 Subject: [PATCH] Go: added function IdentityMatrix. --- generate/template/astronomy.go | 15 +++++++++++++++ source/golang/astronomy.go | 15 +++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/generate/template/astronomy.go b/generate/template/astronomy.go index 244dc0a8..c2788e2b 100644 --- a/generate/template/astronomy.go +++ b/generate/template/astronomy.go @@ -507,6 +507,21 @@ type RotationMatrix struct { Rot [3][3]float64 } +// Creates a rotation matrix that represents no rotation at all. +func IdentityMatrix() RotationMatrix { + r := RotationMatrix{} + r.Rot[0][0] = 1.0 + r.Rot[0][1] = 0.0 + r.Rot[0][2] = 0.0 + r.Rot[1][0] = 0.0 + r.Rot[1][1] = 1.0 + r.Rot[1][2] = 0.0 + r.Rot[2][0] = 0.0 + r.Rot[2][1] = 0.0 + r.Rot[2][2] = 1.0 + return r +} + type Refraction int const ( diff --git a/source/golang/astronomy.go b/source/golang/astronomy.go index 4e5a2a6a..ffff74dc 100644 --- a/source/golang/astronomy.go +++ b/source/golang/astronomy.go @@ -507,6 +507,21 @@ type RotationMatrix struct { Rot [3][3]float64 } +// Creates a rotation matrix that represents no rotation at all. +func IdentityMatrix() RotationMatrix { + r := RotationMatrix{} + r.Rot[0][0] = 1.0 + r.Rot[0][1] = 0.0 + r.Rot[0][2] = 0.0 + r.Rot[1][0] = 0.0 + r.Rot[1][1] = 1.0 + r.Rot[1][2] = 0.0 + r.Rot[2][0] = 0.0 + r.Rot[2][1] = 0.0 + r.Rot[2][2] = 1.0 + return r +} + type Refraction int const (