-
Notifications
You must be signed in to change notification settings - Fork 0
/
line.lisp
47 lines (36 loc) · 1.04 KB
/
line.lisp
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
(in-package :cl-tuples)
(def-tuple-type line2d
:tuple-element-type single-float
:initial-element 0.0f0
:elements (sx sy ex ey))
(def-tuple-type line3d
:tuple-element-type single-float
:initial-element 0.0f0
:elements (sx sy sz ex ey ez))
(def-tuple-op line->vector2d
((line line2d (sx sy ex ey)))
(:return vector2d
(vector2d* (- ex sx) (- ey sy))))
(def-tuple-op line-start->vertex2d
((line line2d (sx sy ex ey)))
(:return vertex2d
(vector2d* sx sy)))
(def-tuple-op line-end->vertex2d
((line line2d (sx sy ex ey)))
(:return vertex2d
(vector2d* sx sy)))
(def-tuple-type line3d
:tuple-element-type single-float
:elements (sx sy sz ex ey ez))
(def-tuple-op line->vector3d
((line line3d (sx sy ex ey)))
(:return vector3d
(vector3d* (- ex sx) (- ey sy) (- ez sz))))
(def-tuple-op line-start->vertex3d
((line line3d (sx sy ex ey)))
(:return vertex3d
(vector3d* sx sy sz)))
(def-tuple-op line-end->vertex3d
((line line3d (sx sy ex ey)))
(:return vertex3d
(vector3d* sx sy sz)))