structuraid_core 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3be903647819b8980e89e0f8e1e984c3696735a254d10cc8de3a8928d56dac88
4
- data.tar.gz: d8c3b1c9b7aa1a8adf9d0edf4c82210c49ee2813bd9c309de0ec296018438231
3
+ metadata.gz: e6a3c25bdfad6f0af2c266ad01cf0321e74780e4366a9a0b941e37c108f6d152
4
+ data.tar.gz: 60afe6f91b70f5acd7ac3d12b1e0c33282afed9620f2c55ee2c29ada6fe3295f
5
5
  SHA512:
6
- metadata.gz: 4ea5df93f54fb0c95583a88c8b1006f89ca5cdd69b50f952d00361980b2fe350be17883b762ce67151a111ad0a0d7b714e3562e6a2d45bede013308f780bad86
7
- data.tar.gz: 8403c78e6ea124d31d38e87a6fbe2731f957acc8974337586c8c340ab847360f8426ce05b770740c3bd7ab858cb8c6d99213b59bb82bdd00e7cf2824987428c9
6
+ metadata.gz: fc6983c21cb7278bb90e9b2b3d4a68e6c873e1fd7de57205724344385200e4674c05fceb61c02342a4329c5ce1515636c614ec8c55d5dba6952f08cd595a309b
7
+ data.tar.gz: da91f2acb4102987f40c8d05b314727349782e0ac170859423460e131aa6b5793c4761066c583b0c6836d1db0392f47b574911faf75368fef61ebf4b4485497e
data/.rubocop.yml CHANGED
@@ -25,6 +25,12 @@ RSpec/MultipleMemoizedHelpers:
25
25
  RSpec/NestedGroups:
26
26
  Enabled: false
27
27
 
28
+ RSpec/ContainExactly:
29
+ Enabled: false
30
+
31
+ RSpec/MatchArray:
32
+ Enabled: false
33
+
28
34
  Lint/MissingSuper:
29
35
  Enabled: false
30
36
 
@@ -0,0 +1,27 @@
1
+ module StructuraidCore
2
+ module DesignCodes
3
+ module ACI31819
4
+ module RC
5
+ module Footings
6
+ class MinHeight
7
+ include DesignCodes::Utils::CodeRequirement
8
+ use_schema DesignCodes::Schemas::RC::Footings::MinHeightSchema
9
+
10
+ MIN_HEIGHT = 150
11
+ CODE_REFERENCE = 'ACI 318-19 13.3.1.2'.freeze
12
+
13
+ def call
14
+ return true if bottom_rebar_effective_height >= MIN_HEIGHT
15
+
16
+ raise RequirementNotFulfilledError.new(
17
+ :min_height,
18
+ "Effective Height #{bottom_rebar_effective_height} is below #{MIN_HEIGHT} mininmum",
19
+ CODE_REFERENCE
20
+ )
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,81 @@
1
+ module StructuraidCore
2
+ module DesignCodes
3
+ module ACI31819
4
+ module RC
5
+ module Footings
6
+ class PunchingShearCapacity
7
+ COLUMN_LOCATION_FACTORS = {
8
+ interior: 40,
9
+ border: 30,
10
+ corner: 20
11
+ }.freeze
12
+
13
+ include DesignCodes::Utils::CodeRequirement
14
+ use_schema DesignCodes::Schemas::RC::Footings::PunchingShearCapacitySchema
15
+
16
+ # ACI 318-19 22.6.5.2
17
+ def call
18
+ [
19
+ basic_shear_capacity,
20
+ shear_capacity_modified_by_column_size,
21
+ shear_capacity_modified_by_column_location
22
+ ].min
23
+ end
24
+
25
+ private
26
+
27
+ def basic_shear_capacity
28
+ @basic_shear_capacity ||= 0.33 * Math.sqrt(design_compression_strength) *
29
+ light_concrete_modification_factor *
30
+ critical_section_perimeter *
31
+ effective_height *
32
+ size_effect_factor
33
+ end
34
+
35
+ def shear_capacity_modified_by_column_size
36
+ @shear_capacity_modified_by_column_size ||= 0.17 * Math.sqrt(design_compression_strength) *
37
+ light_concrete_modification_factor *
38
+ critical_section_perimeter *
39
+ effective_height *
40
+ (1 + 2 / column_aspect_ratio) *
41
+ size_effect_factor
42
+ end
43
+
44
+ def shear_capacity_modified_by_column_location
45
+ @shear_capacity_modified_by_column_location ||= 0.083 * Math.sqrt(design_compression_strength) *
46
+ light_concrete_modification_factor *
47
+ critical_section_perimeter *
48
+ effective_height *
49
+ column_location_factor *
50
+ size_effect_factor
51
+ end
52
+
53
+ def column_aspect_ratio
54
+ @column_aspect_ratio ||= column_sizes.max / column_sizes.min
55
+ end
56
+
57
+ def column_sizes
58
+ @column_sizes ||= [column_section_width.to_f, column_section_height.to_f]
59
+ end
60
+
61
+ def column_location_factor
62
+ unless COLUMN_LOCATION_FACTORS.keys.include?(column_location)
63
+ raise DesignCodes::UnrecognizedValueError.new('column_location', column_location)
64
+ end
65
+
66
+ @column_location_factor ||= COLUMN_LOCATION_FACTORS[column_location].to_f *
67
+ effective_height / critical_section_perimeter + 2
68
+ end
69
+
70
+ def size_effect_factor
71
+ @size_effect_factor ||= [
72
+ 1.0,
73
+ Math.sqrt(2 / (1 + 0.004 * effective_height))
74
+ ].min
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,38 @@
1
+ module StructuraidCore
2
+ module DesignCodes
3
+ module NSR10
4
+ module RC
5
+ module Footings
6
+ class MinHeight
7
+ include DesignCodes::Utils::CodeRequirement
8
+ use_schema DesignCodes::Schemas::RC::Footings::MinHeightSchema
9
+
10
+ MIN_HEIGHT_MAPPINGS = {
11
+ over_soil: 150,
12
+ over_piles: 300
13
+ }.freeze
14
+
15
+ CODE_REFERENCE = 'NSR-10 C.15.7'.freeze
16
+
17
+ def call
18
+ support_type = params.support_type || :over_soil
19
+ unless MIN_HEIGHT_MAPPINGS.keys.include?(support_type)
20
+ raise UnrecognizedValueError.new(:support_type, support_type)
21
+ end
22
+
23
+ min_height = MIN_HEIGHT_MAPPINGS[support_type]
24
+
25
+ return true if bottom_rebar_effective_height >= min_height
26
+
27
+ raise RequirementNotFulfilledError.new(
28
+ :min_height,
29
+ "Height #{bottom_rebar_effective_height} is below #{min_height} mininmum",
30
+ CODE_REFERENCE
31
+ )
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,71 @@
1
+ module StructuraidCore
2
+ module DesignCodes
3
+ module NSR10
4
+ module RC
5
+ module Footings
6
+ class PunchingShearCapacity
7
+ COLUMN_LOCATION_FACTORS = {
8
+ interior: 40,
9
+ border: 30,
10
+ corner: 20
11
+ }.freeze
12
+
13
+ include DesignCodes::Utils::CodeRequirement
14
+ use_schema DesignCodes::Schemas::RC::Footings::PunchingShearCapacitySchema
15
+
16
+ # NSR-10 C.11.11.2.1
17
+ def call
18
+ [
19
+ basic_shear_capacity,
20
+ shear_capacity_modified_by_column_size,
21
+ shear_capacity_modified_by_column_location
22
+ ].min
23
+ end
24
+
25
+ private
26
+
27
+ def basic_shear_capacity
28
+ @basic_shear_capacity ||= 0.33 * Math.sqrt(design_compression_strength) *
29
+ light_concrete_modification_factor *
30
+ critical_section_perimeter *
31
+ effective_height
32
+ end
33
+
34
+ def shear_capacity_modified_by_column_size
35
+ @shear_capacity_modified_by_column_size ||= 0.17 * Math.sqrt(design_compression_strength) *
36
+ light_concrete_modification_factor *
37
+ critical_section_perimeter *
38
+ effective_height *
39
+ (1 + 2 / column_aspect_ratio)
40
+ end
41
+
42
+ def shear_capacity_modified_by_column_location
43
+ @shear_capacity_modified_by_column_location ||= 0.083 * Math.sqrt(design_compression_strength) *
44
+ light_concrete_modification_factor *
45
+ critical_section_perimeter *
46
+ effective_height *
47
+ column_location_factor
48
+ end
49
+
50
+ def column_aspect_ratio
51
+ @column_aspect_ratio ||= column_sizes.max / column_sizes.min
52
+ end
53
+
54
+ def column_sizes
55
+ @column_sizes ||= [column_section_width.to_f, column_section_height.to_f]
56
+ end
57
+
58
+ def column_location_factor
59
+ unless COLUMN_LOCATION_FACTORS.keys.include?(column_location)
60
+ raise DesignCodes::UnrecognizedValueError.new('column_location', column_location)
61
+ end
62
+
63
+ @column_location_factor ||= COLUMN_LOCATION_FACTORS[column_location].to_f *
64
+ effective_height / critical_section_perimeter + 2
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,16 @@
1
+ module StructuraidCore
2
+ module DesignCodes
3
+ module Schemas
4
+ module RC
5
+ module Footings
6
+ class MinHeightSchema
7
+ include DesignCodes::Utils::SchemaDefinition
8
+
9
+ required_params %i[bottom_rebar_effective_height]
10
+ optional_params %i[support_type]
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,25 @@
1
+ module StructuraidCore
2
+ module DesignCodes
3
+ module Schemas
4
+ module RC
5
+ module Footings
6
+ class PunchingShearCapacitySchema
7
+ include DesignCodes::Utils::SchemaDefinition
8
+
9
+ required_params %i[
10
+ column_section_width
11
+ column_section_height
12
+ design_compression_strength
13
+ critical_section_perimeter
14
+ effective_height
15
+ light_concrete_modification_factor
16
+ column_location
17
+ ]
18
+
19
+ optional_params []
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -18,6 +18,9 @@ module StructuraidCore
18
18
  def call(params = {})
19
19
  schema_klass.validate!(params)
20
20
  sanitized_params = schema_klass.structurize(params)
21
+ sanitized_params.members.each do |param_name|
22
+ define_method(param_name) { sanitized_params[param_name] }
23
+ end
21
24
 
22
25
  obj = new(sanitized_params)
23
26
  obj.call
@@ -1,3 +1,5 @@
1
+ require 'matrix'
2
+
1
3
  module StructuraidCore
2
4
  module Elements
3
5
  module Reinforcement
@@ -44,7 +46,13 @@ module StructuraidCore
44
46
  offset ||= 0.5 * diameter
45
47
 
46
48
  [@start_location, @end_location].each do |location|
47
- location.value_3 = above_middle ? location.value_3 - offset : location.value_3 + offset
49
+ location.update_from_vector(
50
+ Vector[
51
+ location.value_1,
52
+ location.value_2,
53
+ above_middle ? location.value_3 - offset : location.value_3 + offset
54
+ ]
55
+ )
48
56
  end
49
57
  end
50
58
 
@@ -67,9 +75,9 @@ module StructuraidCore
67
75
  def length
68
76
  vector = length_vector
69
77
 
70
- vector.value_x = 0 if @distribution_direction == :length_1
71
- vector.value_y = 0 if @distribution_direction == :length_2
72
- vector.value_z = 0 if @distribution_direction == :length_3
78
+ vector[0] = 0 if @distribution_direction == :length_1
79
+ vector[1] = 0 if @distribution_direction == :length_2
80
+ vector[2] = 0 if @distribution_direction == :length_3
73
81
 
74
82
  vector.magnitude
75
83
  end
@@ -77,11 +85,11 @@ module StructuraidCore
77
85
  private
78
86
 
79
87
  def length_vector
80
- Engineering::Vector.new(
81
- value_x: @end_location.value_1 - @start_location.value_1,
82
- value_y: @end_location.value_2 - @start_location.value_2,
83
- value_z: @end_location.value_3 - @start_location.value_3
84
- )
88
+ Vector[
89
+ @end_location.value_1 - @start_location.value_1,
90
+ @end_location.value_2 - @start_location.value_2,
91
+ @end_location.value_3 - @start_location.value_3
92
+ ]
85
93
  end
86
94
  end
87
95
  end
@@ -7,7 +7,10 @@ module StructuraidCore
7
7
 
8
8
  def initialize(footing:, load_from_column:, section_direction:)
9
9
  if ORTHOGONALITIES.none?(section_direction)
10
- raise Engineering::Analysis::SectionDirectionError.new(section_direction, ORTHOGONALITIES)
10
+ raise Engineering::Analysis::SectionDirectionError.new(
11
+ section_direction,
12
+ ORTHOGONALITIES
13
+ )
11
14
  end
12
15
 
13
16
  @footing = footing
@@ -5,6 +5,5 @@ module StructuraidCore
5
5
  end
6
6
  end
7
7
 
8
- require_relative 'vector'
9
8
  require_relative 'analysis/footing/centric_isolated'
10
9
  require_relative 'locations/base'
@@ -1,8 +1,10 @@
1
+ require 'matrix'
2
+
1
3
  module StructuraidCore
2
4
  module Engineering
3
5
  module Locations
4
6
  class Absolute < Base
5
- attr_accessor :value_x, :value_y, :value_z
7
+ attr_reader :value_x, :value_y, :value_z
6
8
 
7
9
  def initialize(value_x:, value_y:, value_z:)
8
10
  @value_x = value_x.to_f
@@ -10,8 +12,14 @@ module StructuraidCore
10
12
  @value_z = value_z.to_f
11
13
  end
12
14
 
13
- def to_a
14
- [@value_x, @value_y, @value_z]
15
+ def to_matrix
16
+ Matrix.column_vector(
17
+ [
18
+ value_x,
19
+ value_y,
20
+ value_z
21
+ ]
22
+ )
15
23
  end
16
24
  end
17
25
  end
@@ -9,3 +9,4 @@ end
9
9
 
10
10
  require_relative 'absolute'
11
11
  require_relative 'relative'
12
+ require_relative 'coordinates_system'
@@ -0,0 +1,60 @@
1
+ require 'matrix'
2
+
3
+ module StructuraidCore
4
+ module Engineering
5
+ module Locations
6
+ class CoordinatesSystem < Base
7
+ attr_reader :relative_locations, :axis_1
8
+
9
+ def initialize(anchor_location:, relative_locations: [])
10
+ @anchor_location = anchor_location
11
+ @relative_locations = relative_locations
12
+ @axis_1 = Vector[1.0, 0.0, 0.0]
13
+ @axis_3 = Vector[0.0, 0.0, 1.0]
14
+ end
15
+
16
+ def align_axis_1_with(vector:)
17
+ relative_locations.each { |relative_location| rotate_axes(relative_location, theta(vector)) }
18
+ @axis_1 = vector.normalize
19
+ end
20
+
21
+ def add_location(relative_location)
22
+ relative_locations << relative_location
23
+ end
24
+
25
+ def axis_2
26
+ axis_3.cross_product axis_1
27
+ end
28
+
29
+ private
30
+
31
+ attr_reader :axis_3
32
+
33
+ def theta(vector)
34
+ unitary_vector = vector.normalize
35
+ return Math.acos(axis_1.inner_product(unitary_vector)) if axis_1.cross_product(unitary_vector)[2].zero?
36
+
37
+ Math.asin(axis_1.cross_product(unitary_vector)[2])
38
+ end
39
+
40
+ def rotate_axes(relative_location, theta)
41
+ transformed = rotation_matrix(theta) * relative_location.to_matrix
42
+ transformed_vector = Vector[
43
+ transformed[0, 0],
44
+ transformed[1, 0],
45
+ transformed[2, 0]
46
+ ]
47
+ relative_location.update_from_vector(transformed_vector)
48
+ end
49
+
50
+ def rotation_matrix(theta)
51
+ Matrix[
52
+ [Math.cos(theta), Math.sin(theta), 0.0],
53
+ [-Math.sin(theta), Math.cos(theta), 0.0],
54
+ [0.0, 0.0, 1.0]
55
+ ]
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
@@ -1,14 +1,44 @@
1
+ require 'matrix'
2
+
1
3
  module StructuraidCore
2
4
  module Engineering
3
5
  module Locations
4
6
  class Relative < Base
5
- attr_accessor :value_1, :value_2, :value_3
7
+ attr_reader :value_1, :value_2, :value_3
8
+
9
+ def self.from_matrix(matrix)
10
+ new(
11
+ value_1: matrix[0, 0],
12
+ value_2: matrix[1, 0],
13
+ value_3: matrix[2, 0]
14
+ )
15
+ end
6
16
 
7
17
  def initialize(value_1:, value_2:, value_3:)
8
18
  @value_1 = value_1.to_f
9
19
  @value_2 = value_2.to_f
10
20
  @value_3 = value_3.to_f
11
21
  end
22
+
23
+ def to_matrix
24
+ Matrix.column_vector(
25
+ [
26
+ value_1,
27
+ value_2,
28
+ value_3
29
+ ]
30
+ )
31
+ end
32
+
33
+ def update_from_vector(vector)
34
+ @value_1 = vector[0]
35
+ @value_2 = vector[1]
36
+ @value_3 = vector[2]
37
+ end
38
+
39
+ def to_vector
40
+ Vector[value_1, value_2, value_3]
41
+ end
12
42
  end
13
43
  end
14
44
  end
@@ -0,0 +1,15 @@
1
+ module StructuraidCore
2
+ module DesignCodes
3
+ class RequirementNotFulfilledError < StandardError
4
+ attr_reader :requirement, :message, :code_reference
5
+
6
+ def initialize(requirement, message, code_reference)
7
+ @requirement = requirement
8
+ @message = message
9
+ @code_reference = code_reference
10
+
11
+ super(message)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,9 @@
1
+ module StructuraidCore
2
+ module DesignCodes
3
+ class UnrecognizedValueError < StandardError
4
+ def initialize(name, value)
5
+ super("#{value} for #{name} param couldnt be recognized")
6
+ end
7
+ end
8
+ end
9
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module StructuraidCore
4
- VERSION = '0.1.1'
4
+ VERSION = '0.1.3'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: structuraid_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pradaing
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-03-14 00:00:00.000000000 Z
11
+ date: 2023-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: byebug
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: 0.22.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: matrix
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 0.4.2
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 0.4.2
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: rake
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -144,11 +158,17 @@ files:
144
158
  - lib/structuraid_core/db/base.rb
145
159
  - lib/structuraid_core/db/rebars.yml
146
160
  - lib/structuraid_core/design_codes/aci_318_19/rc/elastic_modulus.rb
161
+ - lib/structuraid_core/design_codes/aci_318_19/rc/footings/min_height.rb
162
+ - lib/structuraid_core/design_codes/aci_318_19/rc/footings/punching_shear_capacity.rb
147
163
  - lib/structuraid_core/design_codes/base.rb
148
164
  - lib/structuraid_core/design_codes/nsr_10/rc/elastic_modulus.rb
165
+ - lib/structuraid_core/design_codes/nsr_10/rc/footings/min_height.rb
166
+ - lib/structuraid_core/design_codes/nsr_10/rc/footings/punching_shear_capacity.rb
149
167
  - lib/structuraid_core/design_codes/resolver.rb
150
168
  - lib/structuraid_core/design_codes/schemas/empty_schema.rb
151
169
  - lib/structuraid_core/design_codes/schemas/rc/elastic_modulus_schema.rb
170
+ - lib/structuraid_core/design_codes/schemas/rc/footings/min_height_schema.rb
171
+ - lib/structuraid_core/design_codes/schemas/rc/footings/punching_shear_capacity_schema.rb
152
172
  - lib/structuraid_core/design_codes/utils/code_requirement.rb
153
173
  - lib/structuraid_core/design_codes/utils/schema_definition.rb
154
174
  - lib/structuraid_core/elements/base.rb
@@ -165,11 +185,13 @@ files:
165
185
  - lib/structuraid_core/engineering/base.rb
166
186
  - lib/structuraid_core/engineering/locations/absolute.rb
167
187
  - lib/structuraid_core/engineering/locations/base.rb
188
+ - lib/structuraid_core/engineering/locations/coordinates_system.rb
168
189
  - lib/structuraid_core/engineering/locations/relative.rb
169
- - lib/structuraid_core/engineering/vector.rb
170
190
  - lib/structuraid_core/errors/base.rb
171
191
  - lib/structuraid_core/errors/design_codes/missing_param_error.rb
192
+ - lib/structuraid_core/errors/design_codes/requirement_not_fulfilled_error.rb
172
193
  - lib/structuraid_core/errors/design_codes/unknown_design_code_error.rb
194
+ - lib/structuraid_core/errors/design_codes/unrecognized_value_error.rb
173
195
  - lib/structuraid_core/errors/engineering/analysis/section_direction_error.rb
174
196
  - lib/structuraid_core/errors/reinforcement/empty_layers.rb
175
197
  - lib/structuraid_core/errors/reinforcement/invalid_distribution_direction.rb
@@ -182,7 +204,6 @@ files:
182
204
  - lib/structuraid_core/materials/steel.rb
183
205
  - lib/structuraid_core/version.rb
184
206
  - sig/structuraid_core.rbs
185
- - structuraid_core.gemspec
186
207
  homepage: https://github.com/PradaIng/structuraid-core
187
208
  licenses:
188
209
  - MIT
@@ -190,7 +211,7 @@ metadata:
190
211
  homepage_uri: https://github.com/PradaIng/structuraid-core
191
212
  source_code_uri: https://github.com/PradaIng/structuraid-core
192
213
  changelog_uri: https://github.com/PradaIng/structuraid-core/blob/main/CHANGELOG.md
193
- post_install_message:
214
+ post_install_message:
194
215
  rdoc_options: []
195
216
  require_paths:
196
217
  - lib
@@ -205,8 +226,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
205
226
  - !ruby/object:Gem::Version
206
227
  version: '0'
207
228
  requirements: []
208
- rubygems_version: 3.3.7
209
- signing_key:
229
+ rubygems_version: 3.3.26
230
+ signing_key:
210
231
  specification_version: 4
211
232
  summary: Gem with core utilities and functionality to design building structures
212
233
  test_files: []
@@ -1,35 +0,0 @@
1
- module StructuraidCore
2
- module Engineering
3
- class Vector < Base
4
- attr_accessor :value_x, :value_y, :value_z
5
-
6
- def self.with_value(value:, direction:)
7
- new(
8
- value_x: value.to_f * direction[0],
9
- value_y: value.to_f * direction[1],
10
- value_z: value.to_f * direction[2]
11
- )
12
- end
13
-
14
- def initialize(value_x:, value_y:, value_z:)
15
- @value_x = value_x.to_f
16
- @value_y = value_y.to_f
17
- @value_z = value_z.to_f
18
- end
19
-
20
- def magnitude
21
- Math.sqrt(value_x**2 + value_y**2 + value_z**2)
22
- end
23
-
24
- def direction
25
- vector_magnitude = magnitude
26
-
27
- [
28
- @value_x / vector_magnitude,
29
- @value_y / vector_magnitude,
30
- @value_z / vector_magnitude
31
- ]
32
- end
33
- end
34
- end
35
- end
@@ -1,50 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'lib/structuraid_core/version'
4
-
5
- Gem::Specification.new do |spec|
6
- spec.name = 'structuraid_core'
7
- spec.version = StructuraidCore::VERSION
8
- spec.authors = ['Pradaing']
9
- spec.email = ['engineering@pradic.co']
10
-
11
- spec.summary = 'Gem with core utilities and functionality to design building structures'
12
-
13
- description = <<-DESCRIPTION
14
- structuraid_core is a gem that offers a set of functionalities to assist in the design building structures.
15
- DESCRIPTION
16
- spec.description = description.strip
17
-
18
- spec.homepage = 'https://github.com/PradaIng/structuraid-core'
19
- spec.license = 'MIT'
20
- spec.required_ruby_version = '>= 3.1.2'
21
-
22
- # spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
23
- spec.metadata['homepage_uri'] = spec.homepage
24
- spec.metadata['source_code_uri'] = spec.homepage
25
- spec.metadata['changelog_uri'] = 'https://github.com/PradaIng/structuraid-core/blob/main/CHANGELOG.md'
26
-
27
- # Specify which files should be added to the gem when it is released.
28
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
29
- spec.files = Dir.chdir(__dir__) do
30
- `git ls-files -z`.split("\x0").reject do |f|
31
- (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
32
- end
33
- end
34
- spec.bindir = 'exe'
35
- spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
36
- spec.require_paths = ['lib']
37
-
38
- spec.add_development_dependency 'byebug', '~> 11.1.3'
39
- spec.add_development_dependency 'guard-rspec', '~> 4.7.3'
40
- spec.add_development_dependency 'rspec', '~> 3.11.0'
41
- spec.add_development_dependency 'rubocop', '~> 1.41.1'
42
- spec.add_development_dependency 'rubocop-rspec', '~> 2.16.0'
43
- spec.add_development_dependency 'simplecov', '~> 0.22.0'
44
-
45
- spec.add_dependency 'rake', '~> 13.0.6'
46
- spec.add_dependency 'require_all', '~> 3.0.0'
47
-
48
- # For more information and examples about making a new gem, check out our
49
- # guide at: https://bundler.io/guides/creating_gem.html
50
- end