FermiQC / Molecules.jl

Library that handles atom structures as XYZ files and properties derived from it.
MIT License
13 stars 10 forks source link

`rotation_matrix` working? #7

Closed gustavojra closed 3 years ago

gustavojra commented 3 years ago

I tried the following:

julia> v = [1.0, 1.0, 0.0]
julia> z = [0.0, 0.0, 1.0]
julia> M = rotation_matrix(z, 45.0)
julia> M * v
3-element Vector{Float64}:
 -0.3255815357163887
  1.3762255133518482
  0.0

Since v has an angle of 45 deg with either x or y, should this rotation about z yield a vector along x (or y depending on the direction that it is rotating?)

sgoodlett commented 3 years ago

Yeah, this is what happens when you don't convert from degrees to radians.......

I will fix this and include in my next push.

gustavojra commented 3 years ago

Ok, makes sense. So two things

In Julia, a function f normally has another version fd e.g. cosd for degrees. Maybe you could have a rotarion_matrixd? Or just add a keyword argument.

gustavojra commented 3 years ago

Not really a bug why the tag? :laughing:

sgoodlett commented 3 years ago

This issue has been fixed as there are now three functions for generating rotation matrices. rotation_matrix which accepts an angle in radians, rotation_matrixd which accepts an angle in degrees, and Cn which creates an n-fold rotation and is a nicer way to write things when looking for symmetry.