Aeon Engine c550894
AeonGames Open Source Game Engine
Loading...
Searching...
No Matches
Plane.cpp
1/*
2Copyright (C) 2017,2019,2025 Rodrigo Jose Hernandez Cordoba
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16#include <stdexcept>
17#include "3DMath.h"
18#include "aeongames/Plane.hpp"
19#include "aeongames/AABB.hpp"
21
22namespace AeonGames
23{
24 Plane::Plane() = default;
25 Plane::Plane ( float aNormalX, float aNormalY, float aNormalZ, float aDistance ) : mNormal ( aNormalX, aNormalY, aNormalZ ), mDistance ( aDistance )
26 {
27 float length = sqrtf ( Dot ( mNormal, mNormal ) );
28 if ( !length )
29 {
30 std::cout << LogLevel::Error << "Zero lenght normal passed to plane constructor." << std::endl;
31 throw std::runtime_error ( "Zero lenght normal passed to plane constructor." );
32 }
33 mNormal /= length;
34 mDistance /= length;
35 }
36
38 = default;
39
40 const Vector3 & Plane::GetNormal() const
41 {
42 return mNormal;
43 }
44
45 const float & Plane::GetDistance() const
46 {
47 return mDistance;
48 }
49}
Inline functions related to 3D Math.
Header for the axis aligned bounding box class.
Defines log severity levels and stream output for the AeonGames engine.
Header for the plane class.
DLL const float & GetDistance() const
Get the distance from the origin to the plane.
Definition Plane.cpp:45
DLL const Vector3 & GetNormal() const
Get the plane normal vector.
Definition Plane.cpp:40
DLL ~Plane()
destructor.
DLL Plane()
Default constructor.
3D vector class.
Definition Vector3.hpp:32
<- This is here just for the literals
Definition AABB.hpp:31
DLL const float Dot(const Vector3 &aLhs, const Vector3 &aRhs)
Compute the dot product of two vectors.
Definition Vector3.cpp:249
@ Error
Error conditions.
Definition LogLevel.hpp:33