opynsim
Unofficial C++ Documentation
Loading...
Searching...
No Matches
plane_functions.h
Go to the documentation of this file.
1#pragma once
2
10
11namespace osc
12{
13 // returns an `AnalyticPlane` converted from a point on a plane's surface, plus the plane's normal direction
14 constexpr AnalyticPlane to_analytic_plane(const Vector3& point, const Vector3& normal)
15 {
16 return AnalyticPlane{.distance = dot(point, normal), .normal = normal };
17 }
18
19 // returns an `AnalyticPlane` converted from a (point-normal form) `Plane`
21 {
22 return AnalyticPlane{.distance = dot(plane.origin, plane.normal), .normal = plane.normal};
23 }
24
25 // returns the signed distance between the (normal-oriented) surface of `plane` and `vector`
27 {
28 return dot(vector, plane.normal) - plane.distance;
29 }
30
31 // returns the signed distance between the (normal-oriented) surface of `plane` and `vector`
32 constexpr float signed_distance_between(const Plane& plane, const Vector3& vector)
33 {
34 return dot(vector, plane.normal) - dot(plane.origin, plane.normal);
35 }
36
37 // tests if `aabb` is entirely in front of `plane`
38 inline bool is_in_front_of(const AnalyticPlane& plane, const AABB& aabb)
39 {
40 // originally found in: https://learnopengl.com/Guest-Articles/2021/Scene/Frustum-Culling
41 // which was based on : https://gdbooks.gitbooks.io/3dcollisions/content/Chapter2/static_aabb_plane.html
42 const float r = dot(half_widths_of(aabb), abs(plane.normal));
44 }
45
46 // tests if `aabb` is entirely in front of `plane`
47 inline bool is_in_front_of(const Plane& plane, const AABB& aabb)
48 {
50 }
51}
Definition custom_decoration_generator.h:5
constexpr AnalyticPlane to_analytic_plane(const Vector3 &point, const Vector3 &normal)
Definition plane_functions.h:14
constexpr Vector3 half_widths_of(const AABB &aabb)
Definition aabb_functions.h:32
constexpr Vector3 centroid_of(const AABB &aabb)
Definition aabb_functions.h:20
constexpr float signed_distance_between(const AnalyticPlane &plane, const Vector3 &vector)
Definition plane_functions.h:26
constexpr T dot(T x, T y)
Definition geometric_functions.h:29
bool is_in_front_of(const AnalyticPlane &plane, const AABB &aabb)
Definition plane_functions.h:38
T abs(T num)
Definition common_functions.h:24
constexpr U to(T &&value)
Definition conversion.h:56
Definition aabb.h:14
Definition analytic_plane.h:15
float distance
Definition analytic_plane.h:19
Definition plane.h:16