Class: Ephem::Segments::OrientationSegment

Inherits:
BaseSegment
  • Object
show all
Includes:
ChebyshevType2, OrientationSource
Defined in:
lib/ephem/segments/orientation_segment.rb

Overview

Binary PCK orientation segment (data type 2): the orientation of a body frame relative to an inertial reference frame, stored as three Euler angles in Chebyshev coefficients.

Constant Summary collapse

COMPONENT_COUNT =

phi, theta, psi

3

Constants inherited from BaseSegment

BaseSegment::TARGET_NAMES

Instance Attribute Summary

Attributes inherited from BaseSegment

#center, #daf, #end_jd, #source, #start_jd, #target

Instance Method Summary collapse

Methods included from OrientationSource

#compute, #compute_and_differentiate

Methods included from ChebyshevType2

#clear_data

Methods inherited from BaseSegment

#clear_data, #compute, #compute_and_differentiate, #covers?, #to_s

Methods included from Core::CalendarCalculations

format_date, julian_to_gregorian

Constructor Details

#initialize(daf:, source:, descriptor:) ⇒ OrientationSegment

Returns a new instance of OrientationSegment.



14
15
16
17
18
# File 'lib/ephem/segments/orientation_segment.rb', line 14

def initialize(daf:, source:, descriptor:)
  super
  @data_loaded = false
  @data_lock = Mutex.new
end

Instance Method Details

#angles_at(tdb, tdb2 = 0.0) ⇒ Core::Orientation+

Euler angles at the given time, without rates.

Parameters:

  • tdb (Numeric, Array<Numeric>)

    Time(s) in TDB Julian Date

  • tdb2 (Numeric) (defaults to: 0.0)

    Optional fractional part of TDB date

Returns:

Raises:



31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/ephem/segments/orientation_segment.rb', line 31

def angles_at(tdb, tdb2 = 0.0)
  load_data
  tdb_seconds = convert_to_seconds(tdb, tdb2)

  case tdb_seconds
  when Numeric
    to_orientation(generate_position(tdb_seconds))
  else
    tdb_seconds.map do |seconds|
      to_orientation(generate_position(seconds))
    end
  end
end

#describe(verbose: false) ⇒ Object



79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/ephem/segments/orientation_segment.rb', line 79

def describe(verbose: false)
  start_date = format_date(*julian_to_gregorian(@start_jd))
  end_date = format_date(*julian_to_gregorian(@end_jd))

  description =
    "#{start_date}..#{end_date} Type #{@data_type} orientation of " \
    "frame #{body} relative to frame #{reference_frame}"
  return description unless verbose

  <<~DESCRIPTION.chomp
    #{description}
    source=#{@source}
  DESCRIPTION
end

#matrix_at(tdb, tdb2 = 0.0) ⇒ Array<Array<Float>>+

The reference-frame to body-fixed rotation matrix at the given time, built from the 3-1-3 Euler angles. See Core::Orientation#to_matrix.

Parameters:

  • tdb (Numeric, Array<Numeric>)

    Time(s) in TDB Julian Date

  • tdb2 (Numeric) (defaults to: 0.0)

    Optional fractional part of TDB date

Returns:

  • (Array<Array<Float>>, Array<Array<Array<Float>>>)

    a 3x3 matrix, or one per time for an array input

Raises:



74
75
76
77
# File 'lib/ephem/segments/orientation_segment.rb', line 74

def matrix_at(tdb, tdb2 = 0.0)
  angles = angles_at(tdb, tdb2)
  angles.is_a?(Array) ? angles.map(&:to_matrix) : angles.to_matrix
end

#orientation_at(tdb, tdb2 = 0.0) ⇒ Core::Orientation+

Euler angles and their rates at the given time.

Parameters:

  • tdb (Numeric, Array<Numeric>)

    Time(s) in TDB Julian Date

  • tdb2 (Numeric) (defaults to: 0.0)

    Optional fractional part of TDB date

Returns:

Raises:



52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/ephem/segments/orientation_segment.rb', line 52

def orientation_at(tdb, tdb2 = 0.0)
  load_data
  tdb_seconds = convert_to_seconds(tdb, tdb2)

  case tdb_seconds
  when Numeric
    to_orientation(*generate_single(tdb_seconds))
  else
    generate_multiple(tdb_seconds).map do |angles, rates|
      to_orientation(angles, rates)
    end
  end
end