Closed Megidd closed 1 year ago
What about just making "Quaternion" an object within the sdf package itself? ie- it would have access to private members within M44.
A couple of other points...
btw - looking at M22/33/44 references I think the argument could be made to split off matrix operations into their own package. Maybe Quaternions could join them there.
What about just making "Quaternion" an object within the sdf package itself?
... Maybe Quaternions could join them there.
Eventually, I ended up using the Quaternion provided by this Go pkg rather than my own custom Quaternion logic:
https://github.com/go-gl/mathgl
https://github.com/go-gl/mathgl/blob/e426c0894fa41bc41ac04704eef3ac4011b19ecf/mgl32/quat.go#L32
Data types need to be converted of course :slightly_smiling_face:
- Doing m[i][j] = k is probably nicer than doing m.Set(i,j,k)
btw - looking at M22/33/44 references I think the argument could be made to split off matrix operations into their own package...
I guess to do the above points, heavy modifications are needed. Probably affecting many other things. Maybe a heavy restructuring needs rigorous testing. A bit risky maybe :thinking:
- What about M22 and M33?
I'm going to modify I modified the PR so that the same Get
and Set
methods are provided for M22 and M33 too :heavy_check_mark: Just a simple way to have access to matrix values for now.
So are you doing 16 set's to initialise the M44 for your quaternion stuff? Not very efficient... What about:
func NewM44(x []float64) M44
which initialises based on up to 16 values out of x
E.g.
m := sdf.NewM33([]float64{ 0,1,2, 3,4,5, 6,7,8, })
I'd be curious to benchmark differences between type built with arrays vs type built with named elements.
E.g.
M44 as [16]float64 M44 as struct{x00,x01,x02..... float64}
I guess they should be the same.
The former representation makes any sort of indexed access very simple. The latter representations is good for 2d/3d vectors where you can do v.X, v.Y, v.Z
But for a matrix maybe I should convert the representation to a x[i] form internally.
So are you doing 16 set's to initialise the M44 for your quaternion stuff? Not very efficient... What about:
func NewM44(x []float64) M44
which initialises based on up to 16 values out of x
E.g.
m := sdf.NewM33([]float64{ 0,1,2, 3,4,5, 6,7,8, })
Makes sense. I'm going to modify I modified the PR accordingly :+1:
I'd be curious to benchmark differences between type built with arrays vs type built with named elements.
E.g.
M44 as [16]float64 M44 as struct{x00,x01,x02..... float64}
I guess they should be the same.
The former representation makes any sort of indexed access very simple. The latter representations is good for 2d/3d vectors where you can do v.X, v.Y, v.Z
But for a matrix maybe I should convert the representation to a x[i] form internally.
Funny. TIL: ChatGPTs opinion is worth about as much as the opinion of any rando on the internet, in fact it's probably an amalgam of the opinion of said randos.
Problem
There is no public method to declare a new instance of
sdf.M44
with the initialization of its values.The fields of the
sdf.M44
are all private:Why
The reason that I'm running into this problem is that I need to create a
Quaternion
type:But, the last statement cannot be done, I mean:
There is no way to initialize a
sdf.M44
, as far as I understand. Am I right? :roll_eyes: