Skip to content

Instantly share code, notes, and snippets.

@bysreg
Created December 3, 2017 16:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bysreg/b72298be4ed22b189f9dc6ae8cbb55d7 to your computer and use it in GitHub Desktop.
Save bysreg/b72298be4ed22b189f9dc6ae8cbb55d7 to your computer and use it in GitHub Desktop.
Get positive and negative point of AABB relative to a plane (a positive point is defined as a point that is most aligned with plane's normal whereas negative point is vice versa)
Vec3f GetPointPositive(const AABB& a, const Vec3f& v)
{
Vec3f ret(
(v.x > 0 ? a.max.x : a.min.x),
(v.y > 0 ? a.max.y : a.min.y),
(v.z > 0 ? a.max.z : a.min.z)
);
return ret;
}
Vec3f GetPointNegative(const AABB& a, const Vec3f& v)
{
Vec3f ret(
(v.x > 0 ? a.min.x : a.max.x),
(v.y > 0 ? a.min.y : a.max.y),
(v.z > 0 ? a.min.z : a.max.z)
);
return ret;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment