cross

cross multiplication for compaitable vectors.

cross
(
size_t N
size_t K
T
E
alias string S1
alias string S2
)
(
in Vector!(N, T, S1) a
,
in Vector!(K, E, S2) b
)
if (
(
(
K == 3 ||
K == 0
)
&&
(
N == 3 ||
N == 0
)
)
&&
)

Examples

auto x = vec3(1,0,0);
auto y = vecD(0,1,0);
auto z = vecD(0,0,1);

assert( eq( cross(x,y), z ) );
assert( eq( cross(y,z), x ) );
assert( eq( cross(y,x), -z ) );
assert( eq( cross(x,z), -y ) );
assert( eq( cross(z,x), y ) );

auto fy = vecD(0,1,0,0);
assert( mustExcept({ auto fz = x * fy; }) );
auto cfy = vec4(0,1,0,0);
static assert( !__traits(compiles,x*cfy) );

Meta