-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
213 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// test vec3 | ||
// including .cross() and .dot(), which were added in 1.5.4.2 | ||
// vec3 is a primitive type | ||
|
||
@(1,0,0) => vec3 a; | ||
// declare another | ||
@(0,1,0) => vec3 b; | ||
|
||
// add them | ||
a + b => vec3 sum; | ||
// difference | ||
a - b => vec3 diff; | ||
// cross product | ||
a * b => vec3 c; | ||
// another way to do cross product (function) | ||
a.cross(b) => vec3 cross; | ||
// dot product (function) | ||
a.dot(b) => float dot; | ||
|
||
// print sum! | ||
<<< "sum:", sum >>>; | ||
// print difference | ||
<<< "diff:", diff >>>; | ||
// print cross product | ||
<<< "cross product:", c >>>; | ||
<<< "cross product (function):", cross >>>; | ||
// print dot product | ||
<<< "dot product:", dot >>>; | ||
|
||
// array | ||
[ a, b, @(-1,1,0) ] @=> vec3 group[]; | ||
// print them | ||
<<< group[0], group[1], group[2] >>>; | ||
|
||
// another v | ||
vec3 v; | ||
// set value | ||
v.set( 2,2,2 ); | ||
// print magnitude | ||
<<< "magnitude:", v.magnitude() >>>; | ||
// normalize | ||
v.normalize(); | ||
// print vector | ||
<<< "normalize:", v >>>; | ||
|
||
// multiply | ||
5 * v => vec3 v2; | ||
// print result | ||
<<< "scalar multiply:", v2 >>>; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
sum: #(1.0000,1.0000,0.0000) | ||
diff: #(1.0000,-1.0000,0.0000) | ||
cross product: #(0.0000,0.0000,1.0000) | ||
cross product (function): #(0.0000,0.0000,1.0000) | ||
dot product: 0.000000 | ||
#(1.0000,0.0000,0.0000) #(0.0000,1.0000,0.0000) #(-1.0000,1.0000,0.0000) | ||
magnitude: 3.464102 | ||
normalize: #(0.5774,0.5774,0.5774) | ||
scalar multiply: #(2.8868,2.8868,2.8868) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// 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 >>>; | ||
<<< "cross product (function):", cross >>>; | ||
// print dot product | ||
<<< "dot product:", dot >>>; | ||
|
||
// array | ||
[ a, b, c ] @=> vec4 group[]; | ||
|
||
// print them | ||
<<< group[0], group[1], group[2] >>>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
sum: #(6.0000,8.0000,10.0000,12.0000) | ||
diff: #(-4.0000,-4.0000,-4.0000,-4.0000) | ||
cross product: #(-4.0000,8.0000,-4.0000,0.0000) | ||
cross product (function): #(-4.0000,8.0000,-4.0000,0.0000) | ||
dot product: 70.000000 | ||
#(1.0000,2.0000,3.0000,4.0000) #(5.0000,6.0000,7.0000,8.0000) #(-4.0000,8.0000,-4.0000,0.0000) |