Formula Student Autonomous Systems
The code for the main driverless system
Loading...
Searching...
No Matches
plane.cpp
Go to the documentation of this file.
1#include <utils/plane.hpp>
2
3Plane::Plane(double a, double b, double c, double d) : a(a), b(b), c(c), d(d) {}
4
5Plane::Plane() : a(0), b(0), c(0), d(0) {}
6
7double Plane::get_a() const { return a; }
8
9double Plane::get_b() const { return b; }
10
11double Plane::get_c() const { return c; }
12
13double Plane::get_d() const { return d; }
14
15double Plane::get_distance_to_point(float x, float y, float z) const {
16 double numerator = std::abs(a * x + b * y + c * z + d);
17 double denominator = std::sqrt(a * a + b * b + c * c);
18 return numerator / denominator;
19}
20
22 a += other.a;
23 b += other.b;
24 c += other.c;
25 d += other.d;
26 return *this;
27}
28
29Plane& Plane::operator/=(double scalar) {
30 if (scalar != 0.0) {
31 a /= scalar;
32 b /= scalar;
33 c /= scalar;
34 d /= scalar;
35 }
36 return *this;
37}
The Plane class represents a 3D plane defined by its equation ax + by + cz + d = 0.
Definition plane.hpp:12
double d
Definition plane.hpp:84
double get_b() const
Getter - Get the b component of the plane.
Definition plane.cpp:9
double get_a() const
Getter - Get the a component of the plane.
Definition plane.cpp:7
Plane & operator+=(const Plane &other)
Overloads the += operator to add another plane to this plane.
Definition plane.cpp:21
double get_c() const
Getter - Get the c component of the plane.
Definition plane.cpp:11
double get_distance_to_point(float x, float y, float z) const
Calculates the distance from a point to the plane.
Definition plane.cpp:15
Plane & operator/=(double scalar)
Overloads the /= operator to divide a plane by a scalar.
Definition plane.cpp:29
double c
Definition plane.hpp:83
Plane()
Constructs a new Plane object with default coefficients (0).
Definition plane.cpp:5
double get_d() const
Getter - Get the d component of the plane.
Definition plane.cpp:13
double a
Definition plane.hpp:81
double b
Definition plane.hpp:82