MeshLib C++ Docs
Loading...
Searching...
No Matches
MRCone3.h
Go to the documentation of this file.
1#pragma once
2#include "MRLine3.h"
3
4namespace MR
5{
8
9
11
12template <typename T>
13class Cone3
14{
15public:
17 {}
18
23 Cone3( const Line3<T>& inAxis, T inAngle, T inHeight )
24 :
25 axis( inAxis ),
26 angle( inAngle ),
27 height( inHeight )
28 {}
29
32 {
33 return axis.p;
34 }
36 const Vector3<T>& center( void ) const
37 {
38 return axis.p;
39 }
42 {
43 return axis.d;
44 }
46 const Vector3<T>& direction( void ) const
47 {
48 return axis.d;
49 }
52 {
53 return center();
54 }
56 const Vector3<T>& apex( void ) const
57 {
58 return center();
59 }
60
61 Vector3<T> projectPoint( const Vector3<T>& point ) const
62 {
64 const Vector3<T>& n = direction();
65 const Vector3<T>& center = apex();
66 const T coneAngle = angle;
67
69 auto X = point - center;
70
72 T angleX = std::atan2( cross( n, X ).length(), dot( n, X ) );
73
75 if ( coneAngle + PI_F / 2.0 < angleX )
76 return center;
77
79 auto K = n * MR::dot( X, n );
80 auto XK = ( X - K );
81
84 auto D = K + XK.normalized() * ( K.length() * std::tan( coneAngle ) );
85 auto normD = D.normalized();
87 return normD * dot( normD, X ) + center;
88 }
89
90
91 Line3<T> axis;
93 T angle = 0;
94 T height = 0;
95};
96
97
98
99}
Base class for cone parameterization.
Definition MRCone3.h:14
const Vector3< T > & direction(void) const
main axis direction. It could be non normalized. For any cone point dot( point , direction ) >=0
Definition MRCone3.h:46
T angle
for any cone point dot( point , direction ) >=0
Definition MRCone3.h:93
T height
cone angle, main axis vs side
Definition MRCone3.h:94
Line3< T > axis
Definition MRCone3.h:91
Cone3()
Definition MRCone3.h:16
const Vector3< T > & center(void) const
now we use an apex as center of the cone.
Definition MRCone3.h:36
Vector3< T > & apex(void)
return cone apex position
Definition MRCone3.h:51
Cone3(const Line3< T > &inAxis, T inAngle, T inHeight)
Definition MRCone3.h:23
Vector3< T > & center(void)
now we use an apex as center of the cone.
Definition MRCone3.h:31
Vector3< T > & direction(void)
main axis direction. It could be non normalized. For any cone point dot( point , direction ) >=0
Definition MRCone3.h:41
const Vector3< T > & apex(void) const
return cone apex position
Definition MRCone3.h:56
Vector3< T > projectPoint(const Vector3< T > &point) const
Definition MRCone3.h:61
length
Definition MRObjectDimensionsEnum.h:17
only for bindings generation
Definition MRCameraOrientationPlugin.h:8
Definition MRVector3.h:33