Module: Digiproc::CoreExtensions::VectorExtension::Projection::InstanceMethods
- Defined in:
- lib/extensions/core_extensions.rb
Instance Method Summary collapse
-
#project_onto(vec) ⇒ Object
.project_onto(vector) projects self onto the input vector.
Instance Method Details
#project_onto(vec) ⇒ Object
.project_onto(vector) projects self onto the input vector
94 95 96 97 |
# File 'lib/extensions/core_extensions.rb', line 94 def project_onto(vec) raise ArgumentError.new("Argument must be a Vector") if not vec.is_a? Vector (self.dot(vec) / (vec.r ** 2)) * vec end |