File: OpenSCAD_util.sats

package info (click to toggle)
ats2-lang 0.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 40,064 kB
  • sloc: ansic: 389,637; makefile: 7,123; lisp: 812; sh: 657; php: 573; python: 387; perl: 365
file content (120 lines) | stat: -rw-r--r-- 1,830 bytes parent folder | download | duplicates (4)
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
(* ****** ****** *)
(*
** For implementing a DSL
** that supports ATS and OpenSCAD co-programming
*)
(* ****** ****** *)

#staload "./OpenSCAD.sats"

(* ****** ****** *)
//
datatype
vector2 =
VECTOR2 of (double, double)
datatype
vector3 =
VECTOR3 of (double, double, double)
//
(* ****** ****** *)
//
typedef p2d = point2
typedef p3d = point3
//
typedef v2d = vector2
typedef v3d = vector3
//
(* ****** ****** *)
//
fun
point2vector_2d(point2): v2d
fun
vector2point_2d(vector2): p2d
//
fun
point2vector_3d(point3): v3d
fun
vector2point_3d(vector3): p3d
//
(* ****** ****** *)
//
overload
p2v2d with point2vector_2d
overload
v2p2d with vector2point_2d
//
overload
p2v3d with point2vector_3d
overload
v2p3d with vector2point_3d
//
(* ****** ****** *)
//
fun
length_v2d(vector2): double
fun
length_v3d(vector3): double
//
overload length with length_v2d
overload length with length_v3d
//
(* ****** ****** *)
//
fun
distance_p2d_p2d
  (point2, point2): double
fun
distance_p3d_p3d
  (point3, point3): double
//
overload
distance with distance_p2d_p2d
overload
distance with distance_p3d_p3d
//
(* ****** ****** *)
//
fun
add_p3d_v3d
  : (p3d, v3d) -> p3d
fun
sub_p3d_v3d
  : (p3d, v3d) -> p3d
fun
sub_p3d_p3d
  : (p3d, p3d) -> v3d
//
overload + with add_p3d_v3d
overload - with sub_p3d_v3d
overload - with sub_p3d_p3d
//
(* ****** ****** *)
//
fun
add_v3d_v3d
  : (v3d, v3d) -> v3d
fun
sub_v3d_v3d
  : (v3d, v3d) -> v3d
//
overload + with add_v3d_v3d
overload - with sub_v3d_v3d
//
(* ****** ****** *)
fun
mul_int_v3d : (int, v3d) -> v3d
fun
div_v3d_int : (v3d, int) -> v3d
fun
mul_float_v3d : (double, v3d) -> v3d
fun
div_v3d_float : (v3d, double) -> v3d
//
overload * with mul_int_v3d
overload * with mul_float_v3d
overload / with div_v3d_int
overload / with div_v3d_float
//
(* ****** ****** *)

(* end of [OpenSCAD_util.sats] *)