Class: Microstation::Point3d

Inherits:
Object
  • Object
show all
Defined in:
lib/microstation/point3d.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#xObject (readonly)

Returns the value of attribute x.



25
26
27
# File 'lib/microstation/point3d.rb', line 25

def x
  @x
end

#yObject (readonly)

Returns the value of attribute y.



25
26
27
# File 'lib/microstation/point3d.rb', line 25

def y
  @y
end

#zObject (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

Returns:

  • (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_cartesianObject



55
56
# File 'lib/microstation/point3d.rb', line 55

def to_cartesian
end

#zeroObject



51
52
53
# File 'lib/microstation/point3d.rb', line 51

def zero
  new(0.0, 0.0, 0, 0)
end