1 (in-package :cl-tuples
)
7 (def-tuple-type vector2d
8 :tuple-element-type fast-float
12 (export-tuple-operations vector2d
)
14 (def-tuple-type vector3d
15 :tuple-element-type fast-float
16 :initial-element
0.0f0
19 (export-tuple-operations vector3d
)
22 (def-tuple-type vertex2d
23 :tuple-element-type fast-float
24 :initial-element
0.0f0
27 (export-tuple-operations vertex3d
)
29 (def-tuple-type vertex3d
30 :tuple-element-type fast-float
31 :initial-element
0.0f0
34 (export-tuple-operations vertex3d
)
38 (def-tuple-op vector2d-scale
*
44 (vector2d-key-values :initial-element s
))))
46 (def-tuple-op vector2d-dot
*
51 (+) (vector2d-map* (*) veca vecb
))))
53 (def-tuple-op vector2d-length-square
*
54 ((vec vector2d
(x y
)))
56 (vector2d-dot* vec vec
)))
58 (def-tuple-op vector2d-length
*
59 ((vec vector2d
(x y
)))
61 (sqrt (vector2d-length-square* vec
))))
63 (def-tuple-op vector2d-normal
*
64 ((vec vector2d
(x y
)))
68 (/ (vector2d-length* vec
)))))
70 (def-tuple-op vector2d-vertex2d
*
71 ((vec vector2d
(x y
)))
73 (vertex3d-values* x y
1.0f0
)))
75 (def-tuple-op vertex2d-vector2d
*
76 ((vert vertex2d
(x y w
)))
78 (vector2d-values* x y
)))
80 (def-tuple-op vector3d-scale
*
85 (vector3d-key-values :initial-element s
)
88 (def-tuple-op vector3d-dot
*
89 ((veca vector3d
(xa ya za
))
90 (vecb vector3d
(xb yb zb
)))
93 (+) (vector3d-map* (*) veca vecb
))))
95 (def-tuple-op vector3d-length
*
98 (sqrt (vector3d-dot* vec vec
))))
100 (def-tuple-op vector3d-difference
*
104 (vector3d-map* (-) veca vecb
)))
106 (def-tuple-op vector3d-sum
*
110 (vector3d-map* (+) veca vecb
)))
112 (def-tuple-op vector3d-normal
*
117 (/ (vector3d-length* vec
)))))
119 (def-tuple-op vector3d-vertex3d
*
120 ((vec vector3d
(x y z
)))
122 (vertex3d-values* x y z
1.0f0
)))
124 (def-tuple-op vertex3d-vector3d
*
125 ((vert vertex3d
(x y z w
)))
127 (vector3d-values* x y z
)))
129 (def-tuple-op vector3d-cross
*
130 ((lhs vector3d
(lhs-x lhs-y lhs-z
))
131 (rhs vector3d
(rhs-x rhs-y rhs-z
)))
134 (- (* lhs-y rhs-z
) (* lhs-z rhs-y
))
135 (- (* lhs-z rhs-x
) (* lhs-x rhs-z
))
136 (- (* lhs-x rhs-y
) (* lhs-y rhs-x
)))))
138 (def-tuple-op vertex3d-distance
*
143 (vector3d-difference*
144 (vertex3d-vector3d* end
)
145 (vertex3d-vector3d* start
)))))
147 (def-tuple-op delta-vector3d
*
151 (vector3d-difference* end start
)))
155 ;; convert 2 3d vectors to angle axis
157 ;; construct 44 matrix from 3 / a2 3d vectors