Class: StructuraidCore::Engineering::Locations::Relative
- Defined in:
- lib/structuraid_core/engineering/locations/relative.rb
Instance Attribute Summary collapse
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#value_1 ⇒ Object
Returns the value of attribute value_1.
-
#value_2 ⇒ Object
Returns the value of attribute value_2.
-
#value_3 ⇒ Object
Returns the value of attribute value_3.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(value_1:, value_2:, value_3:, label: nil) ⇒ Relative
constructor
A new instance of Relative.
- #to_matrix ⇒ Object
- #to_vector ⇒ Object
- #update_from_vector(vector) ⇒ Object
Constructor Details
#initialize(value_1:, value_2:, value_3:, label: nil) ⇒ Relative
Returns a new instance of Relative.
28 29 30 31 32 33 34 |
# File 'lib/structuraid_core/engineering/locations/relative.rb', line 28 def initialize(value_1:, value_2:, value_3:, label: nil) @value_1 = value_1.to_f @value_2 = value_2.to_f @value_3 = value_3.to_f @label = label&.to_sym end |
Instance Attribute Details
#label ⇒ Object (readonly)
Returns the value of attribute label.
7 8 9 |
# File 'lib/structuraid_core/engineering/locations/relative.rb', line 7 def label @label end |
#value_1 ⇒ Object
Returns the value of attribute value_1.
8 9 10 |
# File 'lib/structuraid_core/engineering/locations/relative.rb', line 8 def value_1 @value_1 end |
#value_2 ⇒ Object
Returns the value of attribute value_2.
8 9 10 |
# File 'lib/structuraid_core/engineering/locations/relative.rb', line 8 def value_2 @value_2 end |
#value_3 ⇒ Object
Returns the value of attribute value_3.
8 9 10 |
# File 'lib/structuraid_core/engineering/locations/relative.rb', line 8 def value_3 @value_3 end |
Class Method Details
.from_matrix(matrix, label: nil) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/structuraid_core/engineering/locations/relative.rb', line 19 def self.from_matrix(matrix, label: nil) new( value_1: matrix[0, 0], value_2: matrix[1, 0], value_3: matrix[2, 0], label: ) end |
.from_vector(vector, label: nil) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/structuraid_core/engineering/locations/relative.rb', line 10 def self.from_vector(vector, label: nil) new( value_1: vector[0], value_2: vector[1], value_3: vector[2], label: ) end |
Instance Method Details
#to_matrix ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/structuraid_core/engineering/locations/relative.rb', line 36 def to_matrix Matrix.column_vector( [ value_1, value_2, value_3 ] ) end |
#to_vector ⇒ Object
52 53 54 |
# File 'lib/structuraid_core/engineering/locations/relative.rb', line 52 def to_vector Vector[value_1, value_2, value_3] end |
#update_from_vector(vector) ⇒ Object
46 47 48 49 50 |
# File 'lib/structuraid_core/engineering/locations/relative.rb', line 46 def update_from_vector(vector) @value_1 = vector[0] @value_2 = vector[1] @value_3 = vector[2] end |