File: vec4.ck

package info (click to toggle)
chuck 1.5.5.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 41,056 kB
  • sloc: cpp: 123,473; ansic: 35,893; javascript: 2,111; yacc: 609; makefile: 457; python: 174; perl: 86
file content (30 lines) | stat: -rw-r--r-- 619 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// vec4 is a primitive type
@(1,2,3,4) => vec4 a;
// declare another
@(5,6,7,8) => vec4 b;

// add them
a + b => vec4 sum;
// difference
a - b => vec4 diff;
// cross product (ignores w component)
a * b => vec4 c;
// another way to do cross product (ignores w component)
a.cross(b) => vec4 cross;
// dot product (function)
a.dot(b) => float dot;

// print sum!
<<< "sum:", sum >>>;
// print difference
<<< "diff:", diff >>>;
// print cross product
<<< "cross product:", c >>>;
// print dot product
<<< "dot product:", dot >>>;

// array
[ a, b, c ] @=> vec4 group[];

// print them
<<< group[0], group[1], group[2] >>>;