Module: Astronoby::Rotation

Defined in:
lib/astronoby/rotation.rb

Overview

Builds elementary rotation matrices about the coordinate axes from an Astronoby::Angle.

These use the passive (frame) convention: the matrix expresses a fixed vector in a frame rotated by angle about the axis. This is the convention used throughout the reference-frame chain (precession, nutation, body orientation).

Class Method Summary collapse

Class Method Details

.about_x(angle) ⇒ Matrix

Returns rotation about the x-axis.

Parameters:

Returns:

  • (Matrix)

    rotation about the x-axis



18
19
20
21
22
23
24
25
# File 'lib/astronoby/rotation.rb', line 18

def about_x(angle)
  cosine, sine = angle.cos, angle.sin
  Matrix[
    [1, 0, 0],
    [0, cosine, sine],
    [0, -sine, cosine]
  ]
end

.about_y(angle) ⇒ Matrix

Returns rotation about the y-axis.

Parameters:

Returns:

  • (Matrix)

    rotation about the y-axis



29
30
31
32
33
34
35
36
# File 'lib/astronoby/rotation.rb', line 29

def about_y(angle)
  cosine, sine = angle.cos, angle.sin
  Matrix[
    [cosine, 0, -sine],
    [0, 1, 0],
    [sine, 0, cosine]
  ]
end

.about_z(angle) ⇒ Matrix

Returns rotation about the z-axis.

Parameters:

Returns:

  • (Matrix)

    rotation about the z-axis



40
41
42
43
44
45
46
47
# File 'lib/astronoby/rotation.rb', line 40

def about_z(angle)
  cosine, sine = angle.cos, angle.sin
  Matrix[
    [cosine, sine, 0],
    [-sine, cosine, 0],
    [0, 0, 1]
  ]
end