| Class | RS::Geometry::RSPoint |
| In: |
rsil/geometry/rspoint.rb
|
| Parent: | RS::Geometry::RSTripel |
| Class: | RSPoint |
| File: | rspoint.rb |
| Purpose: | RSPoint represents points with three values: x, y, z. It is used within RSRectangle. |
| Created by: | Mario Pehle, 2006/04/28 |
| Required modules: | - |
| Offers functions: | - |
| DEFAULT_VALUE | = | 0.0 | when one of the three possible attributes is not provided to initialize, this value will be taken. |
| Description: | Creates a RSDimensiion out of the values of a given RSPoint. |
| Precondition: | - |
| Postcondition: | - |
| Exceptions: | - |
| Uses: | RS::Geometry::RSDimension#new |
| Returns: | RSDimension if valid parameter, else nil |
| Parameters: | Name | i/o/io | default | Meaning |
| : | point | i | - | RSPoint, the source point |
# File rsil/geometry/rspoint.rb, line 47
47: def self::as_dimension point
48: if point.kind_of? RS::Geometry::RSTripel
49: return RS::Geometry::RSDimension.new(
50: point.at(0),
51: point.at(1),
52: point.at(2)
53: )
54: end
55: nil
56: end
| Description: | Checks an object whether it is a valid argument for this class. |
| Precondition: | - |
| Postcondition: | - |
| Exceptions: | - |
| Uses: | - |
| Returns: | true if valid, else false |
| Parameters: | Name | i/o/io | default | Meaning |
| : | value | i | - | Object, the object to check |
# File rsil/geometry/rspoint.rb, line 93
93: def self::is_valid? value
94: return false if value.nil? or !value.respond_to?(:to_f)
95: true
96: end
| Description: | Creates a RSPoint. |
| Precondition: | - |
| Postcondition: | Created object has three values, accessable via RSPoint#[]. |
| Exceptions: | ArgumentError |
| Uses: | RSPoint#is_valid? |
| Returns: | RSPoint |
| Parameters: | Name | i/o/io | default | Meaning |
| : | x | i | DEFAULT_VALUE | Float, the value for x |
| : | y | i | DEFAULT_VALUE | Float, the value for y |
| : | z | i | DEFAULT_VALUE | Float, the value for z |
# File rsil/geometry/rspoint.rb, line 130
130: def initialize x=DEFAULT_VALUE, y=DEFAULT_VALUE, z=DEFAULT_VALUE
131: unless self.is_valid?(x) or self.is_valid?(y) or self.is_valid?(z)
132: raise ArgumentError, "Can not convert arguemnts."
133: else
134: super
135: end
136: self
137: end
| Description: | Creates a RSDimension out of the values of a given RSPoint. If no point is given, the method returns the actual RSPoint as a RSDimension. |
| Precondition: | - |
| Postcondition: | - |
| Exceptions: | - |
| Uses: | RS::Geometry::RSDimension#new |
| Returns: | RSDimension if valid parameter, else nil |
| Parameters: | Name | i/o/io | default | Meaning |
| : | point | i | nil | RSPoint, the source point |
# File rsil/geometry/rspoint.rb, line 71
71: def as_dimension point=nil
72: if point.nil?
73: return RS::Geometry::RSDimension.new(self.at(0), self.at(1), self.at(2))
74: else
75: return self.class.as_dimension(point)
76: end
77: nil
78: end
| Description: | Checks an object whether it is a valid argument for this class. |
| Precondition: | - |
| Postcondition: | - |
| Exceptions: | - |
| Uses: | RSPoint#is_valid? |
| Returns: | true if valid, else false |
| Parameters: | Name | i/o/io | default | Meaning |
| : | value | i | - | Object, the object to check |
# File rsil/geometry/rspoint.rb, line 111
111: def is_valid? value
112: self.class.is_valid? value
113: end
| Description: | Sets the x value of the point. |
| Precondition: | - |
| Postcondition: | Value for x is changed. |
| Exceptions: | - |
| Uses: | RSPoint#[] |
| Returns: | value if valid, else nil |
| Parameters: | Name | i/o/io | default | Meaning |
| : | value | i | - | Float, the value to set |
# File rsil/geometry/rspoint.rb, line 200
200: def x= value
201: return self[0] = value.to_f if self.is_valid? value
202: nil
203: end
| Description: | Sets the y value of the point. |
| Precondition: | - |
| Postcondition: | Value for y is changed. |
| Exceptions: | - |
| Uses: | RSPoint#[] |
| Returns: | value if valid, else nil |
| Parameters: | Name | i/o/io | default | Meaning |
| : | value | i | - | Float, the value to set |
# File rsil/geometry/rspoint.rb, line 218
218: def y= value
219: return self[1] = value.to_f if self.is_valid? value
220: nil
221: end
| Description: | Sets the z value of the point. |
| Precondition: | - |
| Postcondition: | Value for z is changed. |
| Exceptions: | - |
| Uses: | RSPoint#[] |
| Returns: | value if valid, else nil |
| Parameters: | Name | i/o/io | default | Meaning |
| : | value | i | - | Float, the value to set |
# File rsil/geometry/rspoint.rb, line 236
236: def z= value
237: return self[2] = value.to_f if self.is_valid? value
238: nil
239: end