Class: StructuraidCore::Elements::Reinforcement::StraightLongitudinalLayer
- Inherits:
-
Base
- Object
- Base
- StructuraidCore::Elements::Reinforcement::StraightLongitudinalLayer
- Defined in:
- lib/structuraid_core/elements/reinforcement/straight_longitudinal_layer.rb
Constant Summary collapse
- VALID_DIRECTIONS =
%i[length_1 length_2 length_3].freeze
Instance Attribute Summary collapse
-
#amount_of_rebars ⇒ Object
readonly
Returns the value of attribute amount_of_rebars.
-
#rebar ⇒ Object
readonly
Returns the value of attribute rebar.
Instance Method Summary collapse
- #area ⇒ Object
- #centroid_height ⇒ Object
- #diameter ⇒ Object
- #inertia ⇒ Object
-
#initialize(start_location:, end_location:, amount_of_rebars:, rebar:, distribution_direction:) ⇒ StraightLongitudinalLayer
constructor
A new instance of StraightLongitudinalLayer.
- #length ⇒ Object
- #modify_rebar_configuration(amount_of_new_rebars:, new_rebar:, above_middle:) ⇒ Object
- #reposition(above_middle:, offset: nil) ⇒ Object
Constructor Details
#initialize(start_location:, end_location:, amount_of_rebars:, rebar:, distribution_direction:) ⇒ StraightLongitudinalLayer
Returns a new instance of StraightLongitudinalLayer.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/structuraid_core/elements/reinforcement/straight_longitudinal_layer.rb', line 11 def initialize( start_location:, end_location:, amount_of_rebars:, rebar:, distribution_direction: ) if VALID_DIRECTIONS.none?(distribution_direction) raise Elements::Reinforcement::InvalidDistributionDirection.new(distribution_direction, VALID_DIRECTIONS) end @start_location = start_location @end_location = end_location @amount_of_rebars = @rebar = @distribution_direction = distribution_direction end |
Instance Attribute Details
#amount_of_rebars ⇒ Object (readonly)
Returns the value of attribute amount_of_rebars.
7 8 9 |
# File 'lib/structuraid_core/elements/reinforcement/straight_longitudinal_layer.rb', line 7 def @amount_of_rebars end |
#rebar ⇒ Object (readonly)
Returns the value of attribute rebar.
7 8 9 |
# File 'lib/structuraid_core/elements/reinforcement/straight_longitudinal_layer.rb', line 7 def @rebar end |
Instance Method Details
#area ⇒ Object
59 60 61 |
# File 'lib/structuraid_core/elements/reinforcement/straight_longitudinal_layer.rb', line 59 def area @amount_of_rebars * @rebar.area end |
#centroid_height ⇒ Object
67 68 69 |
# File 'lib/structuraid_core/elements/reinforcement/straight_longitudinal_layer.rb', line 67 def centroid_height @start_location.value_3 end |
#diameter ⇒ Object
71 72 73 |
# File 'lib/structuraid_core/elements/reinforcement/straight_longitudinal_layer.rb', line 71 def diameter @rebar.diameter end |
#inertia ⇒ Object
63 64 65 |
# File 'lib/structuraid_core/elements/reinforcement/straight_longitudinal_layer.rb', line 63 def inertia area * centroid_height end |
#length ⇒ Object
75 76 77 78 79 80 81 82 83 |
# File 'lib/structuraid_core/elements/reinforcement/straight_longitudinal_layer.rb', line 75 def length vector = length_vector vector[0] = 0 if @distribution_direction == :length_1 vector[1] = 0 if @distribution_direction == :length_2 vector[2] = 0 if @distribution_direction == :length_3 vector.magnitude end |
#modify_rebar_configuration(amount_of_new_rebars:, new_rebar:, above_middle:) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/structuraid_core/elements/reinforcement/straight_longitudinal_layer.rb', line 29 def ( amount_of_new_rebars:, new_rebar:, above_middle: ) offset = (diameter - .diameter) / 2 offset *= -1 unless above_middle @amount_of_rebars = @rebar = reposition(above_middle:, offset:) @rebar end |
#reposition(above_middle:, offset: nil) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/structuraid_core/elements/reinforcement/straight_longitudinal_layer.rb', line 45 def reposition(above_middle:, offset: nil) offset ||= 0.5 * diameter [@start_location, @end_location].each do |location| location.update_from_vector( Vector[ location.value_1, location.value_2, above_middle ? location.value_3 - offset : location.value_3 + offset ] ) end end |