Ocean
Loading...
Searching...
No Matches
PerspectivePose.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8#ifndef META_OCEAN_GEOMETRY_PERSPECTIVE_POSE_H
9#define META_OCEAN_GEOMETRY_PERSPECTIVE_POSE_H
10
12
13#include "ocean/math/Vector2.h"
14#include "ocean/math/Vector3.h"
15
16namespace Ocean
17{
18
19namespace Geometry
20{
21
22/**
23 * This class is the base class for all perspective pose classes.
24 * @ingroup geometry
25 */
26class OCEAN_GEOMETRY_EXPORT PerspectivePose
27{
28 protected:
29
30 /**
31 * Calculates the two possible solutions for the law of cosines.
32 * @param x1 First leg distance
33 * @param x1_2 Square of the first leg distance
34 * @param cos12 Cosine value of the angle between the two legs
35 * @param d12_2 Square of the far distance
36 * @param x2a First solution of the second leg distance
37 * @param x2b Second solution of the second leg distance
38 * @return True, if succeeded
39 * @tparam T The data type of the scalar
40 */
41 template <typename T>
42 static bool calculateCosineSolutions(const T x1, const T x1_2, const T cos12, const T d12_2, T& x2a, T& x2b);
43
44 /**
45 * Returns the result of the law of cosines.
46 * For valid parameters this result should be zero.
47 * The law is: 0 = x1^2 + x2^2 - 2 * x1 * x2 * cos12 - d12^2
48 * @param x1 First leg distance
49 * @param x1_2 Square of the first leg distance
50 * @param x2 Second leg distance
51 * @param x2_2 Square of the second leg distance
52 * @param cos12 Cosine value of the angle between the two legs
53 * @param d12_2 Square of the far distance
54 * @return Result of the law of cosines
55 * @tparam T The data type of the scalar
56 */
57 template <typename T>
58 static inline T calculateCosineResults(const T x1, const T x1_2, const T x2, const T x2_2, const T cos12, const T d12_2);
59};
60
61template <typename T>
62inline T PerspectivePose::calculateCosineResults(const T x1, const T x1_2, const T x2, const T x2_2, const T cos12, const T d12_2)
63{
64 return x1_2 + x2_2 - 2 * x1 * x2 * cos12 - d12_2;
65}
66
67}
68
69}
70
71#endif // META_OCEAN_GEOMETRY_PERSPECTIVE_POSE_H
This class is the base class for all perspective pose classes.
Definition PerspectivePose.h:27
static T calculateCosineResults(const T x1, const T x1_2, const T x2, const T x2_2, const T cos12, const T d12_2)
Returns the result of the law of cosines.
Definition PerspectivePose.h:62
static bool calculateCosineSolutions(const T x1, const T x1_2, const T cos12, const T d12_2, T &x2a, T &x2b)
Calculates the two possible solutions for the law of cosines.
The namespace covering the entire Ocean framework.
Definition Accessor.h:15