Custom array for 3D-Matrix operations 4x4

I need a structure like that, as a custom array 4x4 for 3D-calculations:

Matrix3D = zeros(Float64, 4, 4)

I tried to define it like that, but i stuck:

struct Matrix3D <: Abstract???
???
end

to use it:

myMatrix3D = Matrix3D ???

assigning values like that:

myMatrix3D[1, 4] = 3.0

or working like that:
myMatrix3D[2, 2] = cos(w); myMatrix3D[2, 3] = -sin(w)
myMatrix3D[3, 2] = sin(w); myMatrix3D[3, 3] = cos(w)

any help for me?

Check out StaticArrays.jl for fixed size arrays and maybe Rotations.jl for rotation matrices.

Will you be using this type as a homogeneous transform (rotation + translation)?

yes, I do

Will you be using this type as a homogeneous transform (rotation + translation)?

yes, I do

Then try https://github.com/FugroRoames/CoordinateTransformations.jl

2 Likes

TY. It’s already known. For me its important to do I by my self (for learling purposes)

1 Like

I would start by learning the AbstractArray interface. Also make sure you’re up on Parametric types since you’ll probably want to encode array size as a parameter. Then try writing a simple custom type from scratch. You can find many examples of simple AbstractArray types at JuliaArrays.

StaticArrays does what you want and would be a good example, but if you haven’t already written a custom AbstractArray type it might be challenging learning: StaticArrays is very sophisticated and has to jump through hoops to handle immutability.

1 Like

I already tried that but i stucked.

A small working example for me would be very helpful

Take a look at MappedArrays and IndirectArrays; they’re both relatively simple.