Skip to content

Commit fcdd801

Browse files
committed
minor vec3 work
1 parent c258fbd commit fcdd801

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

vec3.lua

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -511,15 +511,20 @@ function vec3.dot(a, b)
511511
return a.x * b.x + a.y * b.y + a.z * b.z
512512
end
513513

514-
function vec3.cross(a, b, into)
515-
if not into then into = vec3:zero() end
516-
return into:sset(
514+
function vec3.crossi(a, b)
515+
return a:sset(
517516
a.y * b.z - a.z * b.y,
518517
a.z * b.x - a.x * b.z,
519518
a.x * b.y - a.y * b.x
520519
)
521520
end
522521

522+
vec3.cross_inplace = vec3.crossi
523+
524+
function vec3:cross(b, into)
525+
(into or self:copy()):crossi(b)
526+
end
527+
523528
--scalar projection a onto b
524529
function vec3.sproj(a, b)
525530
local len = b:length()

0 commit comments

Comments
 (0)