# FreeBSD Manual Pages

ARITH3(3) Library Functions Manual ARITH3(3)NAMEadd3, 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 planesSYNOPSIS#include<draw.h>#include<geometry.h>Point3add3(Point3a,Point3b)Point3sub3(Point3a,Point3b)Point3neg3(Point3a)Point3div3(Point3a,doubleb)Point3mul3(Point3a,doubleb)inteqpt3(Point3p,Point3q)intclosept3(Point3p,Point3q,doubleeps)doubledot3(Point3p,Point3q)Point3cross3(Point3p,Point3q)doublelen3(Point3p)doubledist3(Point3p,Point3q)Point3unit3(Point3p)Point3midpt3(Point3p,Point3q)Point3lerp3(Point3p,Point3q,doublealpha)Point3reflect3(Point3p,Point3p0,Point3p1)Point3nearseg3(Point3p0,Point3p1,Point3testp)doublepldist3(Point3p,Point3p0,Point3p1)doublevdiv3(Point3a,Point3b)Point3vrem3(Point3a,Point3b)Point3pn2f3(Point3p,Point3n)Point3ppp2f3(Point3p0,Point3p1,Point3p2)Point3fff2p3(Point3f0,Point3f1,Point3f2)Point3pdiv4(Point3a)Point3add4(Point3a,Point3b)Point3sub4(Point3a,Point3b)DESCRIPTIONThese routines do arithmetic on points and planes in affine or projec- tive 3-space. TypePoint3is typedef struct Point3 Point3; struct Point3{ double x, y, z, w; }; Routines whose names end in3operate on vectors or ordinary points in affine 3-space, represented by their Euclidean(x,y,z)coordinates. (They assumew=1in their arguments, and setw=1in their results.) Name Descriptionadd3Add the coordinates of two points.sub3Subtract coordinates of two points.neg3Negate the coordinates of a point.mul3Multiply coordinates by a scalar.div3Divide coordinates by a scalar.eqpt3Test two points for exact equality.closept3Is the distance between two points smaller thaneps?dot3Dot product.cross3Cross product.len3Distance to the origin.dist3Distance between two points.unit3A unit vector parallel top.midpt3The midpoint of line segmentpq.lerp3Linear interpolation betweenpandq.reflect3The reflection of pointpin the segment joiningp0andp1.nearseg3The closest point totestpon segmentp0p1.pldist3The distance frompto segmentp0p1.vdiv3Vector divide -- the length of the component ofaparallel tob, in units of the length ofb.vrem3Vector remainder -- the component ofaperpendicular tob. Ig- noring roundoff, we haveeqpt3(add3(mul3(b,vdiv3(a,b)),vrem3(a,b)),a). The following routines convert amongst various representations of points and planes. Planes are represented identically to points, by duality; a pointpis on a planeqwheneverp.x*q.x+p.y*q.y+p.z*q.z+p.w*q.w=0. Although when dealing with affine points we assumep.w=1, we can't make the same assumption for planes. The names of these routines are extra-cryptic. They contain anf(for `face') to indicate a plane,pfor a point andnfor a normal vector. The number2abbreviates the word `to.' The number3reminds us, as before, that we're dealing with affine points. Thuspn2f3takes a point and a normal vector and returns the corresponding plane. Name Descriptionpn2f3Compute the plane passing throughpwith normaln.ppp2f3Compute the plane passing through three points.fff2p3Compute the intersection point of three planes. The names of the following routines end in4because they operate on points in projective 4-space, represented by their homogeneous coordi- nates. pdiv4 Perspective division. Dividep.wintop's coordinates, convert- ing to affine coordinates. Ifp.wis zero, the result is the same as the argument. add4 Add the coordinates of two points. sub4 Subtract the coordinates of two points.SOURCE/src/libgeometrySEE ALSOARITH3(3)

NAME | SYNOPSIS | DESCRIPTION | SOURCE | SEE ALSO

Want to link to this manual page? Use this URL:

<https://www.freebsd.org/cgi/man.cgi?query=arith3&sektion=3&manpath=FreeBSD+12.2-RELEASE+and+Ports>