Class: Microstation::Point3d
- Inherits:
-
Object
- Object
- Microstation::Point3d
- Defined in:
- lib/microstation/point3d.rb
Instance Attribute Summary collapse
-
#x ⇒ Object
readonly
Returns the value of attribute x.
-
#y ⇒ Object
readonly
Returns the value of attribute y.
-
#z ⇒ Object
readonly
Returns the value of attribute z.
Class Method Summary collapse
- .cartesian_to_polar(x, y) ⇒ Object
- .from_ole(ole) ⇒ Object
- .from_polar_degrees(r, a) ⇒ Object
- .ole_point3d?(ole) ⇒ Boolean
- .polar_to_cartesian(r, a) ⇒ Object
Instance Method Summary collapse
- #+(other) ⇒ Object
- #-(other) ⇒ Object
-
#initialize(x = 0, y = 0, z = 0) ⇒ Point3d
constructor
A new instance of Point3d.
- #to_cartesian ⇒ Object
- #zero ⇒ Object
Constructor Details
#initialize(x = 0, y = 0, z = 0) ⇒ Point3d
Returns a new instance of Point3d.
27 28 29 30 31 |
# File 'lib/microstation/point3d.rb', line 27 def initialize(x = 0, y = 0, z = 0) @x = x @y = y @z = z end |
Instance Attribute Details
#x ⇒ Object (readonly)
Returns the value of attribute x.
25 26 27 |
# File 'lib/microstation/point3d.rb', line 25 def x @x end |
#y ⇒ Object (readonly)
Returns the value of attribute y.
25 26 27 |
# File 'lib/microstation/point3d.rb', line 25 def y @y end |
#z ⇒ Object (readonly)
Returns the value of attribute z.
25 26 27 |
# File 'lib/microstation/point3d.rb', line 25 def z @z end |
Class Method Details
.cartesian_to_polar(x, y) ⇒ Object
8 9 10 11 12 |
# File 'lib/microstation/point3d.rb', line 8 def cartesian_to_polar(x, y) r = Math.sqrt(x * x + y * y) angle = Angle.radians(Math.atan2(y, x)) [r, angle] end |
.from_ole(ole) ⇒ Object
17 18 19 |
# File 'lib/microstation/point3d.rb', line 17 def from_ole(ole) new(ole.X, ole.Y, ole.Z) end |
.from_polar_degrees(r, a) ⇒ Object
14 15 |
# File 'lib/microstation/point3d.rb', line 14 def from_polar_degrees(r, a) end |
.ole_point3d?(ole) ⇒ Boolean
4 5 6 |
# File 'lib/microstation/point3d.rb', line 4 def ole_point3d?(ole) ole.instance_of?(WIN32OLE_RECORD) && ole.typename == "Point3d" end |
.polar_to_cartesian(r, a) ⇒ Object
21 22 |
# File 'lib/microstation/point3d.rb', line 21 def polar_to_cartesian(r, a) end |
Instance Method Details
#+(other) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/microstation/point3d.rb', line 33 def +(other) case other when Point3d self.class.new(x + other.x, y + other.y, z + other.z) when Array self.class.new(x + other[0], y + other[1]) end end |
#-(other) ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/microstation/point3d.rb', line 42 def -(other) case other when Point3d self.class.new(x - other.x, y - other.y, z - other.z) when Array self.class.new(x - other[0], y - other[1]) end end |
#to_cartesian ⇒ Object
55 56 |
# File 'lib/microstation/point3d.rb', line 55 def to_cartesian end |
#zero ⇒ Object
51 52 53 |
# File 'lib/microstation/point3d.rb', line 51 def zero new(0.0, 0.0, 0, 0) end |