mirror of
https://github.com/vrld/hump.git
synced 2024-11-23 12:24:19 +00:00
Add projection and perpendicular
This commit is contained in:
parent
6315155955
commit
66c0f92a30
@ -102,3 +102,12 @@ end
|
|||||||
function Vector:rotated(phi)
|
function Vector:rotated(phi)
|
||||||
return self:clone():rotate_inplace(phi)
|
return self:clone():rotate_inplace(phi)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Vector:perpendicular()
|
||||||
|
return vector(-self.y, self.x)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Vector:projectOn(v)
|
||||||
|
assert(isvector(v), "invalid argument: cannot project onto anything other than a vector.")
|
||||||
|
return (self * v) * v / v:len2()
|
||||||
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user