1234567891011121314151617181920 |
- #include "core/Plane.h"
- #include "core/Generic.h"
- #include "core/ToString.h"
- void initPlane(Plane* p, const Vector3* a, const Vector3* b, const Vector3* c) {
- cross(&p->abc, sub(b, a), sub(c, a));
- normalize(&p->abc);
- p->d = -dot(&p->abc, b);
- }
- float signedDistance(const Plane* p, const Vector3* v) {
- return dot(&p->abc, v) + p->d;
- }
- size_t toStringPlane(const Plane* p, char* buffer, size_t n) {
- return toString(buffer, n, "(%.3f x + %.3f y + %.3f z + %.3f)",
- (double)p->abc.data[0], (double)p->abc.data[1],
- (double)p->abc.data[2], (double)p->d);
- }
|