Class: StructuraidCore::Engineering::Locations::CoordinatesSystem

Inherits:
Base
  • Object
show all
Defined in:
lib/structuraid_core/engineering/locations/coordinates_system.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(anchor_location:) ⇒ CoordinatesSystem

Returns a new instance of CoordinatesSystem.



9
10
11
12
13
14
# File 'lib/structuraid_core/engineering/locations/coordinates_system.rb', line 9

def initialize(anchor_location:)
  @anchor_location = anchor_location
  @relative_locations = Collection.new
  @axis_1 = Vector[1.0, 0.0, 0.0]
  @axis_3 = Vector[0.0, 0.0, 1.0]
end

Instance Attribute Details

#anchor_locationObject (readonly)

Returns the value of attribute anchor_location.



7
8
9
# File 'lib/structuraid_core/engineering/locations/coordinates_system.rb', line 7

def anchor_location
  @anchor_location
end

#axis_1Object (readonly)

Returns the value of attribute axis_1.



7
8
9
# File 'lib/structuraid_core/engineering/locations/coordinates_system.rb', line 7

def axis_1
  @axis_1
end

#relative_locationsObject (readonly)

Returns the value of attribute relative_locations.



7
8
9
# File 'lib/structuraid_core/engineering/locations/coordinates_system.rb', line 7

def relative_locations
  @relative_locations
end

Instance Method Details

#add_location(relative_location) ⇒ Object



21
22
23
# File 'lib/structuraid_core/engineering/locations/coordinates_system.rb', line 21

def add_location(relative_location)
  relative_locations.add(relative_location)
end

#add_location_from_vector(vector, label:) ⇒ Object



25
26
27
28
# File 'lib/structuraid_core/engineering/locations/coordinates_system.rb', line 25

def add_location_from_vector(vector, label:)
  relative_location = Relative.from_vector(vector, label:)
  add_location(relative_location)
end

#align_axis_1_with(vector:) ⇒ Object



16
17
18
19
# File 'lib/structuraid_core/engineering/locations/coordinates_system.rb', line 16

def align_axis_1_with(vector:)
  relative_locations.each { |relative_location| rotate_axes(relative_location, theta(vector)) }
  @axis_1 = vector.normalize
end

#axis_2Object



36
37
38
# File 'lib/structuraid_core/engineering/locations/coordinates_system.rb', line 36

def axis_2
  axis_3.cross_product axis_1
end

#find_location(label) ⇒ Object



40
41
42
# File 'lib/structuraid_core/engineering/locations/coordinates_system.rb', line 40

def find_location(label)
  relative_locations.find_by_label(label)
end

#find_or_add_location_from_vector(vector, label:) ⇒ Object



30
31
32
33
34
# File 'lib/structuraid_core/engineering/locations/coordinates_system.rb', line 30

def find_or_add_location_from_vector(vector, label:)
  relative_location = Relative.from_vector(vector, label:)

  relative_locations.find_or_add_by_label(relative_location)
end