cross

cross multiplication for compaitable vectors.

cross
(
size_t N
size_t K
T
E
)
(
auto ref const(Vector!(N, T)) a
,
auto ref const(Vector!(K, E)) b
)
if (
(
(
K == 3 ||
K == 0
)
&&
(
N == 3 ||
N == 0
)
)
&&
hasCompMltAndSum!(T, E)
)

Examples

1 auto x = vec3(1,0,0);
2 auto y = vecD(0,1,0);
3 auto z = vecD(0,0,1);
4 
5 assert( eq( cross(x,y), z ) );
6 assert( eq( cross(y,z), x ) );
7 assert( eq( cross(y,x), -z ) );
8 assert( eq( cross(x,z), -y ) );
9 assert( eq( cross(z,x), y ) );
10 
11 auto fy = vecD(0,1,0,0);
12 assertThrown( x * fy );
13 auto cfy = vec4(0,1,0,0);
14 static assert( !__traits(compiles,x*cfy) );

Meta