|
#include <u.h>
#include <libc.h>
#include <geometry.h>
#define DEG 0.01745329251994330 /* π/180 */
typedef struct Point2 Point2;
typedef struct Point3 Point3;
typedef double Matrix[3][3];
typedef double Matrix3[4][4];
typedef struct Quaternion Quaternion;
typedef struct RFrame RFrame;
typedef struct RFrame3 RFrame3;
struct Point2 {
};
struct Point3 {
};
struct Quaternion {
};
struct RFrame {
};
struct RFrame3 {
| |
Point3 p;
Point3 bx, by, bz;
|
};
extern Point2 ZP2;
extern Point3 ZP3;
/* utils */
double flerp(double a, double b, double t)
double fberp(double a, double b, double c, Point3 bc)
double fclamp(double n, double min, double max)
/* Point2 */
Point2 Pt2(double x, double y, double w)
Point2 Vec2(double x, double y)
Point2 addpt2(Point2 a, Point2 b)
Point2 subpt2(Point2 a, Point2 b)
Point2 mulpt2(Point2 p, double s)
Point2 divpt2(Point2 p, double s)
Point2 lerp2(Point2 a, Point2 b, double t)
Point2 berp2(Point2 a, Point2 b, Point2 c, Point3 bc)
double dotvec2(Point2 a, Point2 b)
double vec2len(Point2 v)
Point2 normvec2(Point2 v)
Point2 centroid(Point2 *pts, ulong npts)
Point3 barycoords(Point2 p0, Point2 p1, Point2 p2, Point2 p)
int edgeptcmp(Point2 e0, Point2 e1, Point2 p)
int ptinpoly(Point2 p, Point2 *pts, ulong npts)
/* Point3 */
Point3 Pt3(double x, double y, double z, double w)
Point3 Vec3(double x, double y, double z)
Point3 addpt3(Point3 a, Point3 b)
Point3 subpt3(Point3 a, Point3 b)
Point3 mulpt3(Point3 p, double s)
Point3 divpt3(Point3 p, double s)
Point3 lerp3(Point3 a, Point3 b, double t)
Point3 berp3(Point3 a, Point3 b, Point3 c, Point3 bc)
double dotvec3(Point3 a, Point3 b)
Point3 crossvec3(Point3 a, Point3 b)
double vec3len(Point3 v)
Point3 normvec3(Point3 v)
Point3 centroid3(Point3 *pts, ulong npts)
int lineXsphere(Point3 *rp, Point3 p0, Point3 p1,
| |
| |
Point3 c, double rad, int isaray)
|
|
int ptincylinder(Point3 p, Point3 p0, Point3 p1, double r)
int ptincone(Point3 p, Point3 p0, Point3 p1, double br)
/* Matrix */
void identity(Matrix m)
void addm(Matrix a, Matrix b)
void subm(Matrix a, Matrix b)
void mulm(Matrix a, Matrix b)
void smulm(Matrix m, double s)
void transposem(Matrix m)
double detm(Matrix m)
double tracem(Matrix m)
double minorm(Matrix m, int row, int col)
double cofactorm(Matrix m, int row, int col)
void adjm(Matrix m)
void invm(Matrix m)
Point2 xform(Point2 p, Matrix m)
/* Matrix3 */
void identity3(Matrix3 m)
void addm3(Matrix3 a, Matrix3 b)
void subm3(Matrix3 a, Matrix3 b)
void mulm3(Matrix3 a, Matrix3 b)
void smulm3(Matrix3 m, double s)
void transposem3(Matrix3 m)
double detm3(Matrix3 m)
double tracem3(Matrix3 m)
double minorm3(Matrix3 m, int row, int col)
double cofactorm3(Matrix3 m, int row, int col)
void adjm3(Matrix3 m)
void invm3(Matrix3 m)
Point3 xform3(Point3 p, Matrix3 m)
/* Quaternion */
Quaternion Quat(double r, double i, double j, double k)
Quaternion Quatvec(double r, Point3 v)
Quaternion addq(Quaternion a, Quaternion b)
Quaternion subq(Quaternion a, Quaternion b)
Quaternion mulq(Quaternion q, Quaternion r)
Quaternion smulq(Quaternion q, double s)
Quaternion sdivq(Quaternion q, double s)
double dotq(Quaternion q, Quaternion r)
Quaternion invq(Quaternion q)
double qlen(Quaternion q)
Quaternion normq(Quaternion q)
Quaternion slerp(Quaternion q, Quaternion r, double t)
Quaternion qsandwich(Quaternion q, Quaternion r)
Point3 qsandwichpt3(Quaternion q, Point3 p)
Point3 qrotate(Point3 p, Point3 axis, double θ)
/* RFrame */
void rframematrix(Matrix, RFrame)
void rframematrix3(Matrix3, RFrame3)
Point2 rframexform(Point2 p, RFrame rf)
Point3 rframexform3(Point3 p, RFrame3 rf)
Point2 invrframexform(Point2 p, RFrame rf)
Point3 invrframexform3(Point3 p, RFrame3 rf)
/* Fmt */
#pragma varargck type "v" Point2
#pragma varargck type "V" Point3
int vfmt(Fmt*)
int Vfmt(Fmt*)
void GEOMfmtinstall(void)
|