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
- #+(pt) ⇒ Object
- #-(pt) ⇒ 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.
35 36 37 38 39 |
# File 'lib/microstation/point3d.rb', line 35 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.
33 34 35 |
# File 'lib/microstation/point3d.rb', line 33 def x @x end |
#y ⇒ Object (readonly)
Returns the value of attribute y.
33 34 35 |
# File 'lib/microstation/point3d.rb', line 33 def y @y end |
#z ⇒ Object (readonly)
Returns the value of attribute z.
33 34 35 |
# File 'lib/microstation/point3d.rb', line 33 def z @z end |
Class Method Details
.cartesian_to_polar(x, y) ⇒ Object
13 14 15 16 17 |
# File 'lib/microstation/point3d.rb', line 13 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
23 24 25 |
# File 'lib/microstation/point3d.rb', line 23 def from_ole(ole) new(ole.X, ole.Y, ole.Z) end |
.from_polar_degrees(r, a) ⇒ Object
19 20 21 |
# File 'lib/microstation/point3d.rb', line 19 def from_polar_degrees(r,a) end |
.ole_point3d?(ole) ⇒ Boolean
9 10 11 |
# File 'lib/microstation/point3d.rb', line 9 def ole_point3d?(ole) ole.class == WIN32OLE_RECORD && ole.typename == 'Point3d' end |
.polar_to_cartesian(r, a) ⇒ Object
27 28 29 |
# File 'lib/microstation/point3d.rb', line 27 def polar_to_cartesian(r,a) end |
Instance Method Details
#+(pt) ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/microstation/point3d.rb', line 42 def +(pt) case pt when Point3d self.class.new(self.x + pt.x, self.y + pt.y, self.z + pt.z) when Array self.class.new(self.x + pt[0], self.y + pt[1]) end end |
#-(pt) ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/microstation/point3d.rb', line 51 def -(pt) case pt when Point3d self.class.new(self.x - pt.x, self.y - pt.y, self.z - pt.z) when Array self.class.new(self.x - pt[0], self.y - pt[1]) end end |
#to_cartesian ⇒ Object
64 65 66 |
# File 'lib/microstation/point3d.rb', line 64 def to_cartesian end |
#zero ⇒ Object
60 61 62 |
# File 'lib/microstation/point3d.rb', line 60 def zero new(0.0,0.0,0,0) end |