summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/runtriple.in
blob: 59207294da5e2471c7f05f1fb0215cbe0e9b26a2 (plain)
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/*****
 * runtriple.in
 *
 * Runtime functions for triple operations.
 *
 *****/

triple   => primTriple()

#include "triple.h"
#include "path3.h"
#include "drawelement.h"

using namespace camp;

// Autogenerated routines:


triple :tripleZero()
{
  static triple zero;
  return zero;
}

triple :realRealRealToTriple(real x, real y, real z)
{
  return triple(x,y,z);
}

real xpart:tripleXPart(triple v)
{
  return v.getx();
}

real ypart:tripleYPart(triple v)
{
  return v.gety();
}

real zpart:tripleZPart(triple v)
{
  return v.getz();
}

triple Operator *(real x, triple v)
{
  return x*v;
}

triple Operator *(triple v, real x)
{
  return v*x;
}

triple /(triple v, real x)
{
  return v/x;
}

real length(triple v)
{
  return v.length();
}

real abs(triple v)
{
  return v.length();
}

real abs2(triple v)
{
  return abs2(v);
}

real polar(triple v, bool warn=true)
{
  return v.polar(warn);
}

real azimuth(triple v, bool warn=true)
{
  if(!warn && v.getx() == 0.0 && v.gety() == 0.0) return 0.0;
  return v.azimuth();
}

real colatitude(triple v, bool warn=true)
{
  if(!warn && v.getx() == 0.0 && v.gety() == 0.0 && v.getz() == 0.0) return 0.0;
  return degrees(v.polar());
}

real latitude(triple v, bool warn=true)
{
  if(!warn && v.getx() == 0.0 && v.gety() == 0.0 && v.getz() == 0.0) return 0.0;
  return 90.0-degrees(v.polar());
}

// Return the longitude of v in [0,360).
real longitude(triple v, bool warn=true)
{
  if(!warn && v.getx() == 0.0 && v.gety() == 0.0) return 0.0;
  return principalBranch(degrees(v.azimuth()));
}

triple unit(triple v)
{
  return unit(v);
}

real dot(triple u, triple v)
{
  return dot(u,v);
}

triple cross(triple u, triple v)
{
  return cross(u,v);
}

triple dir(explicit triple z)
{
  return unit(z);
}

triple expi(real polar, real azimuth)
{
  return expi(polar,azimuth);
}

triple dir(real colatitude, real longitude)
{
  return expi(radians(colatitude),radians(longitude));
}

triple realmult(triple u, triple v)
{
  return triple (u.getx()*v.getx(),u.gety()*v.gety(),u.getz()*v.getz());
}

// Return the component of vector v perpendicular to a unit vector u.
triple perp(triple v, triple u)
{
  return perp(v,u);
}

triple bezier(triple a, triple b, triple c, triple d, real t)
{
  real onemt=1-t;
  real onemt2=onemt*onemt;
  return onemt2*onemt*a+t*(3.0*(onemt2*b+t*onemt*c)+t*t*d);
}

triple bezierP(triple a, triple b, triple c, triple d, real t)
{
  return 3.0*(t*t*(d-a+3.0*(b-c))+t*(2.0*(a+c)-4.0*b)+b-a);
}

triple bezierPP(triple a, triple b, triple c, triple d, real t)
{
  return 6.0*(t*(d-a+3.0*(b-c))+a+c)-12.0*b;
}

triple bezierPPP(triple a, triple b, triple c, triple d)
{
  return 6.0*(d-a)+18.0*(b-c);
}