Module: TT::Arc

Defined in:
TT_Lib2/arc.rb

Overview

Collection of Arc methods.

Since:

  • 2.0.0

Class Method Summary collapse

Class Method Details

.circle?(curve) ⇒ Boolean

Returns:

  • (Boolean)

Since:

  • 2.0.0



37
38
39
40
# File 'TT_Lib2/arc.rb', line 37

def self.circle?( curve )
  return false unless self.is?( curve )
return ((curve.end_angle - curve.start_angle).radians >= 360) ? true : false
end

.exploded_center(e1, e2) ⇒ Object

Since:

  • 2.0.0



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'TT_Lib2/arc.rb', line 50

def self.exploded_center(e1, e2)
  # Two edges representing an arc must have the same length and can not
  # be parallel.
  return nil if e1.length != e2.length
  v1 = e1.line[1]
  v2 = e2.line[1]
  return nil if v1.parallel?( v2 )
  # Get mid-point of edges from where intersecting lines will origin.
  m1 = Geom.linear_combination( 0.5, e1.start.position, 0.5, e1.end.position )
  m2 = Geom.linear_combination( 0.5, e2.start.position, 0.5, e2.end.position )
  # Get the vectors for the intersecting lines
  z_axis = v1 * v2
  line1 = [m1, v1 * z_axis]
  line2 = [m2, v2 * z_axis]
  # Return the center
  Geom.intersect_line_line(line1, line2)
end

.is?(curve) ⇒ Boolean

Returns:

  • (Boolean)

Since:

  • 2.0.0



22
23
24
25
# File 'TT_Lib2/arc.rb', line 22

def self.is?( curve )
  return false if curve.respond_to?( :is_polygon? ) && curve.is_polygon?
  curve.is_a?(Sketchup::ArcCurve)
end