32typedef float __attribute__((ext_vector_type(3))) VuoPoint3d;
34#define VuoPoint3d_SUPPORTS_COMPARISON
74static inline VuoPoint3d
VuoPoint3d_make(
float x,
float y,
float z) __attribute__((
const));
77 return (VuoPoint3d){x, y, z};
87 return (VuoPoint3d){ f[0], f[1], f[2] };
105static inline VuoBox VuoBox_make(VuoPoint3d center, VuoPoint3d size) __attribute__((
const));
108 return (
VuoBox){ center, size };
114static inline VuoBox VuoBox_makeWithPoints(
float xmin,
float xmax,
float ymin,
float ymax,
float zmin,
float zmax) __attribute__((
const));
118 (VuoPoint3d){ (xmin+xmax)/2.f, (ymin+ymax)/2.f, (zmin+zmax)/2.f },
119 (VuoPoint3d){ xmax-xmin, ymax-ymin, zmax-zmin }
142 return u.x*v.x+u.y*v.y+u.z*v.z;
151 return sqrtf(a.x*a.x + a.y*a.y + a.z*a.z);
160 return a / sqrtf(a.x * a.x + a.y * a.y + a.z * a.z);
166static inline VuoPoint3d
VuoPoint3d_add(VuoPoint3d a, VuoPoint3d b) __attribute__((
const));
175static inline VuoPoint3d
VuoPoint3d_subtract(VuoPoint3d a, VuoPoint3d b) __attribute__((
const));
188 return (a.x*a.x + a.y*a.y + a.z*a.z);
194static inline VuoPoint3d
VuoPoint3d_divide(VuoPoint3d a, VuoPoint3d b) __attribute__((
const));
212static inline VuoPoint3d
VuoPoint3d_min(
const VuoPoint3d l,
const VuoPoint3d r) __attribute__((
const));
224static inline VuoPoint3d
VuoPoint3d_max(
const VuoPoint3d l,
const VuoPoint3d r) __attribute__((
const));
239 if (fabs(a.x) < 0.000001)
240 a.x = copysign(0.000001, a.x);
241 if (fabs(a.y) < 0.000001)
242 a.y = copysign(0.000001, a.y);
243 if (fabs(a.z) < 0.000001)
244 a.z = copysign(0.000001, a.z);
254 return sqrtf((a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y) + (a.z-b.z)*(a.z-b.z));
260static inline VuoPoint3d
VuoPoint3d_lerp(VuoPoint3d a, VuoPoint3d b,
float t) __attribute__((
const));
263 return a * (1 - t) + b * t;
269static inline VuoPoint3d
VuoPoint3d_scale(VuoPoint3d a, VuoPoint3d b) __attribute__((
const));
283static inline VuoPoint3d
VuoPoint3d_mod(VuoPoint3d a, VuoPoint3d b) __attribute__((
const));
287 a.x - b.x * floorf(a.x / b.x),
288 a.y - b.y * floorf(a.y / b.y),
289 a.z - b.z * floorf(a.z / b.z)
299 p.x =
VuoReal_spring(timeSinceDrop, dropPosition.x, restingPosition.x, period, damping);
300 p.y =
VuoReal_spring(timeSinceDrop, dropPosition.y, restingPosition.y, period, damping);
301 p.z =
VuoReal_spring(timeSinceDrop, dropPosition.z, restingPosition.z, period, damping);
320static inline VuoPoint3d
VuoPoint3d_clampn(VuoPoint3d point, VuoPoint3d limitA, VuoPoint3d limitB)
340 return (VuoPoint3d) {
350static inline VuoPoint3d
VuoPoint3d_snap(VuoPoint3d a, VuoPoint3d center, VuoPoint3d snap)
353 return (VuoPoint3d) {
354 center.x + nonzeroSnap.x * (int)round( (a.x-center.x) / nonzeroSnap.x ),
355 center.y + nonzeroSnap.y * (
int)round( (a.y-center.y) / nonzeroSnap.y ),
356 center.z + nonzeroSnap.z * (int)round( (a.z-center.z) / nonzeroSnap.z )
365 float xmin, ymin, zmin, xmax, ymax, zmax;
370 xmin = fmin(a.center.x - extents_a.x, b.center.x - extents_b.x);
371 xmax = fmax(a.center.x + extents_a.x, b.center.x + extents_b.x);
373 ymin = fmin(a.center.y - extents_a.y, b.center.y - extents_b.y);
374 ymax = fmax(a.center.y + extents_a.y, b.center.y + extents_b.y);
376 zmin = fmin(a.center.z - extents_a.z, b.center.z - extents_b.z);
377 zmax = fmax(a.center.z + extents_a.z, b.center.z + extents_b.z);
387 VuoPoint3d exents = (VuoPoint3d){aabb.size.x / 2.f, aabb.size.y / 2.f};
388 VuoPoint3d min = aabb.center - exents;
389 VuoPoint3d max = aabb.center + exents;
391 return point.x > min.x && point.x < max.x &&
392 point.y > min.y && point.y < max.y &&
393 point.z > min.z && point.z < max.z;
404 return fabs(dist.x) * 2 < size.x &&
405 fabs(dist.y) * 2 < size.y &&
406 fabs(dist.z) * 2 < size.z;