- 3.0.2 core module.
Plane.h
Go to the documentation of this file.
1 /**********************************************************************************************************************
2 This file is part of the Control Toolbox (https://github.com/ethz-adrl/control-toolbox), copyright by ETH Zurich.
3 Licensed under the BSD-2 license (see LICENSE file in main directory)
4 **********************************************************************************************************************/
5 
6 #pragma once
7 
8 namespace ct {
9 namespace core {
10 
12 class Plane
13 {
14 public:
15  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
16 
18  Plane() { coefficients_.setZero(); }
20 
25  Plane(const Eigen::Matrix<double, 4, 1>& coefficients) : coefficients_(coefficients) {}
27 
34  Plane(double a, double b, double c, double d) { coefficients_ << a, b, c, d; }
36 
41  Eigen::Matrix<double, 4, 1>& getCoefficients() { return coefficients_; }
43 
48  double& getCoefficient(size_t i)
49  {
50  if (i >= 4)
51  throw std::runtime_error("Index out of range, should be max 3.");
52  return coefficients_(i);
53  }
54 
56  double a() { return coefficients_[AIdx]; }
58  double b() { return coefficients_[BIdx]; }
60  double c() { return coefficients_[CIdx]; }
62  double d() { return coefficients_[DIdx]; }
64  void set(double a, double b, double c, double d) { coefficients_ << a, b, c, d; };
66 
72  double solveX(double y, double z) { return (d() - b() * y - c() * z) / a(); }
74 
80  double solveY(double x, double z) { return (d() - a() * x - c() * z) / b(); }
82 
88  double solveZ(double x, double y) { return (d() - a() * x - b() * y) / c(); }
89 private:
90  enum
91  {
92  AIdx = 0,
93  BIdx = 1,
94  CIdx = 2,
95  DIdx = 3
96  };
97 
98  Eigen::Matrix<double, 4, 1> coefficients_;
99 };
100 
101 } // namespace core
102 } // namespace ct
103 
104 
105 #pragma once
double d()
get d
Definition: Plane.h:62
Plane(double a, double b, double c, double d)
constructor
Definition: Plane.h:34
double b()
get b
Definition: Plane.h:58
double solveY(double x, double z)
solve for y
Definition: Plane.h:80
Eigen::Matrix< double, 4, 1 > & getCoefficients()
returns the coefficients
Definition: Plane.h:41
double & getCoefficient(size_t i)
returns a single coefficient
Definition: Plane.h:48
EIGEN_MAKE_ALIGNED_OPERATOR_NEW Plane()
default constructor
Definition: Plane.h:18
double solveX(double y, double z)
solve for x
Definition: Plane.h:72
double c()
get c
Definition: Plane.h:60
Implements a geometrical 3D plane of type .
Definition: Plane.h:12
double a()
get a
Definition: Plane.h:56
Plane(const Eigen::Matrix< double, 4, 1 > &coefficients)
constructor
Definition: Plane.h:25
double solveZ(double x, double y)
solve for z
Definition: Plane.h:88