Class: Stagecraft::Bounding::Plane
- Inherits:
-
Object
- Object
- Stagecraft::Bounding::Plane
- Defined in:
- lib/stagecraft/core/bounding.rb
Instance Attribute Summary collapse
-
#constant ⇒ Object
readonly
Returns the value of attribute constant.
-
#normal ⇒ Object
readonly
Returns the value of attribute normal.
Instance Method Summary collapse
- #distance_to_point(point) ⇒ Object
-
#initialize(normal, constant) ⇒ Plane
constructor
A new instance of Plane.
- #intersects_sphere?(sphere) ⇒ Boolean
Constructor Details
#initialize(normal, constant) ⇒ Plane
Returns a new instance of Plane.
83 84 85 86 87 88 89 |
# File 'lib/stagecraft/core/bounding.rb', line 83 def initialize(normal, constant) length = normal.length raise ArgumentError, "plane normal cannot be zero" if length.zero? @normal = normal / length @constant = constant.to_f / length end |
Instance Attribute Details
#constant ⇒ Object (readonly)
Returns the value of attribute constant.
81 82 83 |
# File 'lib/stagecraft/core/bounding.rb', line 81 def constant @constant end |
#normal ⇒ Object (readonly)
Returns the value of attribute normal.
81 82 83 |
# File 'lib/stagecraft/core/bounding.rb', line 81 def normal @normal end |
Instance Method Details
#distance_to_point(point) ⇒ Object
91 92 93 |
# File 'lib/stagecraft/core/bounding.rb', line 91 def distance_to_point(point) normal.dot(point) + constant end |
#intersects_sphere?(sphere) ⇒ Boolean
95 96 97 |
# File 'lib/stagecraft/core/bounding.rb', line 95 def intersects_sphere?(sphere) distance_to_point(sphere.center) >= -sphere.radius end |