Class: Sevgi::Geometry::LengthAngle
- Inherits:
-
Data
- Object
- Data
- Sevgi::Geometry::LengthAngle
- Defined in:
- lib/sevgi/geometry/segment.rb,
lib/sevgi/geometry/segment.rb
Overview
Immutable length/angle constraint used when a full segment is not implied.
Instance Attribute Summary collapse
-
#angle ⇒ Float
readonly
Direction used to derive a segment.
-
#length ⇒ Float
readonly
Non-negative target measure.
Class Method Summary collapse
-
.[](length, angle) ⇒ Sevgi::Geometry::LengthAngle
Creates a length-and-angle constraint.
Instance Method Summary collapse
-
#initialize(length:, angle:) ⇒ void
constructor
Creates a target-measure constraint.
Constructor Details
#initialize(length:, angle:) ⇒ void
Creates a target-measure constraint.
182 183 184 185 186 187 |
# File 'lib/sevgi/geometry/segment.rb', line 182 def initialize(length:, angle:) length = Real[:length, length] Error.("LengthAngle length cannot be negative") if length.negative? super(length:, angle: Real[:angle, angle]) end |
Instance Attribute Details
#angle ⇒ Float (readonly)
Returns direction used to derive a segment.
176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/sevgi/geometry/segment.rb', line 176 LengthAngle = Data.define(:length, :angle) do # Creates a target-measure constraint. # @param length [Numeric] finite non-negative target width or height # @param angle [Numeric] finite direction in degrees # @return [void] # @raise [Sevgi::Geometry::Error] when a component is not finite or length is negative def initialize(length:, angle:) length = Real[:length, length] Error.("LengthAngle length cannot be negative") if length.negative? super(length:, angle: Real[:angle, angle]) end end |
#length ⇒ Float (readonly)
Returns non-negative target measure.
176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/sevgi/geometry/segment.rb', line 176 LengthAngle = Data.define(:length, :angle) do # Creates a target-measure constraint. # @param length [Numeric] finite non-negative target width or height # @param angle [Numeric] finite direction in degrees # @return [void] # @raise [Sevgi::Geometry::Error] when a component is not finite or length is negative def initialize(length:, angle:) length = Real[:length, length] Error.("LengthAngle length cannot be negative") if length.negative? super(length:, angle: Real[:angle, angle]) end end |
Class Method Details
.[](length, angle) ⇒ Sevgi::Geometry::LengthAngle
Creates a length-and-angle constraint.
176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/sevgi/geometry/segment.rb', line 176 LengthAngle = Data.define(:length, :angle) do # Creates a target-measure constraint. # @param length [Numeric] finite non-negative target width or height # @param angle [Numeric] finite direction in degrees # @return [void] # @raise [Sevgi::Geometry::Error] when a component is not finite or length is negative def initialize(length:, angle:) length = Real[:length, length] Error.("LengthAngle length cannot be negative") if length.negative? super(length:, angle: Real[:angle, angle]) end end |