3 add3, sub3, neg3, div3, mul3, eqpt3, closept3, dot3, cross3, len3, dist3, unit3, midpt3, lerp3, reflect3, nearseg3, pldist3, vdiv3, vrem3, pn2f3, ppp2f3, fff2p3, pdiv4, add4, sub4 \- operations on 3-d points and planes
12 Point3 add3(Point3 a, Point3 b)
15 Point3 sub3(Point3 a, Point3 b)
21 Point3 div3(Point3 a, double b)
24 Point3 mul3(Point3 a, double b)
27 int eqpt3(Point3 p, Point3 q)
30 int closept3(Point3 p, Point3 q, double eps)
33 double dot3(Point3 p, Point3 q)
36 Point3 cross3(Point3 p, Point3 q)
42 double dist3(Point3 p, Point3 q)
45 Point3 unit3(Point3 p)
48 Point3 midpt3(Point3 p, Point3 q)
51 Point3 lerp3(Point3 p, Point3 q, double alpha)
54 Point3 reflect3(Point3 p, Point3 p0, Point3 p1)
57 Point3 nearseg3(Point3 p0, Point3 p1, Point3 testp)
60 double pldist3(Point3 p, Point3 p0, Point3 p1)
63 double vdiv3(Point3 a, Point3 b)
66 Point3 vrem3(Point3 a, Point3 b)
69 Point3 pn2f3(Point3 p, Point3 n)
72 Point3 ppp2f3(Point3 p0, Point3 p1, Point3 p2)
75 Point3 fff2p3(Point3 f0, Point3 f1, Point3 f2)
78 Point3 pdiv4(Point3 a)
81 Point3 add4(Point3 a, Point3 b)
84 Point3 sub4(Point3 a, Point3 b)
86 These routines do arithmetic on points and planes in affine or projective 3-space.
93 typedef struct Point3 Point3;
99 Routines whose names end in
101 operate on vectors or ordinary points in affine 3-space, represented by their Euclidean
106 in their arguments, and set
115 Add the coordinates of two points.
118 Subtract coordinates of two points.
121 Negate the coordinates of a point.
124 Multiply coordinates by a scalar.
127 Divide coordinates by a scalar.
130 Test two points for exact equality.
133 Is the distance between two points smaller than
143 Distance to the origin.
146 Distance between two points.
149 A unit vector parallel to
153 The midpoint of line segment
157 Linear interpolation between
163 The reflection of point
165 in the segment joining
183 Vector divide \(em the length of the component of
187 in units of the length of
191 Vector remainder \(em the component of
195 Ignoring roundoff, we have
196 .BR "eqpt3(add3(mul3(b, vdiv3(a, b)), vrem3(a, b)), a)" .
199 The following routines convert amongst various representations of points
200 and planes. Planes are represented identically to points, by duality;
206 .BR p.x*q.x+p.y*q.y+p.z*q.z+p.w*q.w=0 .
207 Although when dealing with affine points we assume
209 we can't make the same assumption for planes.
210 The names of these routines are extra-cryptic. They contain an
212 (for `face') to indicate a plane,
219 abbreviates the word `to.'
222 reminds us, as before, that we're dealing with affine points.
225 takes a point and a normal vector and returns the corresponding plane.
232 Compute the plane passing through
238 Compute the plane passing through three points.
241 Compute the intersection point of three planes.
244 The names of the following routines end in
246 because they operate on points in projective 4-space,
247 represented by their homogeneous coordinates.
250 Perspective division. Divide
254 coordinates, converting to affine coordinates.
257 is zero, the result is the same as the argument.
260 Add the coordinates of two points.
264 Subtract the coordinates of two points.
266 .B /sys/src/libgeometry