- Notifications
You must be signed in to change notification settings - Fork5
DSL and utilities for vector mathematics in Common Lisp
License
inconvergent/cl-veq
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
VEQ is a DSL and a set of utilities for doing dealing with (primarily)1d/2d/3d/nd point vectors and arrays of point vectors. It includes somegeometry and graphics programming utilities like intersection tests and matrixtransforms.
VEQ was written to be the vector library used in my graph data structure,cl-grph, and utilities forgenerative art:auxin.
Seedocs for documentation and symbols.
For more examples go toexamples.
(in-package:veq); fvprogn is a compiler for the veq DSL, and and environment that cointains; many of the vector tools. among other things it handles the !@ triggers for; common nd point vector operations such as f2!@+ for 2d single float point; vector addition, and so on; here are some examples:(fvprogn; xlet makes it convenient to declare typed value packs ("veqs") with the; trigger [t][d]![var], eg. f2!varname. the variable will the be replaced by; the n values inside the scope. (xlet ((f2!a (f212)); (values 1f0 2f0) (f3!varname0); (values 0.0 0.0 0.0) (f2!b (f23100)); (values 3f0 100f0) (line (f2$line3f040f07f03f0)); #(3f0 40f0 7f0 3f0) (xx:s); just :s, as you expect (i3!integervar) (values173); (values 1 7 3) (va (f$_ (loop for v from0 below6; #(0.0 1.0 1.0 collect (list (ff v) (ff (1+ v))))))); 2.0 2.0 3.0; 3.0 4.0 4.0; 5.0 5.0 6.0); vp pretty prints input code and output values (vp (f2len (f2!@*. (f2!@+ a b)0.1))); f2!@*. scales the vector by 0.1 by broadcasting [.] the value over the veq; convenience function to print arrays of vectors: (2$print line); returns line (vp (f2!@$+ vb3f0100f0)); only return vb from index to below 5 (vp (f2!@$+ (?@ va25)3f0100f0)) (vp (f2dot (f2$ va) (f2$ line1))); dot product; can also be written as: (f!@+ (f2!@* (f2$ va) (f2$ line1)); where (f2$ va) is the first veq in va, and (f2$ line 1) is the second; veq in line (vp (f2cross (f2$ line01))); cross product; equivalent to: (vp (f2cross (f2$ line0) (f2$ line1))) (vp (f2!@$+ (f2$zero3)3f01f0)) (vp (f21_@$f2len (f2!@$+ (f2$zero3)3f01f0))) (vp (f21_@$+ vb)); TODO, improve example for new features )))
veq now tentatively includes packagesrnd andsrnd for random numbergeneration.rnd uses native random number generator andsrnd is for veryfast (low quality) random number generation with explicit state. Eg. for use inthreads for 3d rendering.
Both packages currently only support single floats. and they lack thef prefixused inveq. This might change in the future.
About
DSL and utilities for vector mathematics in Common Lisp
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.