mirror of https://github.com/CGAL/cgal
added volume, squared_area function
This commit is contained in:
parent
f635fe2d55
commit
4e9510bcaa
|
|
@ -1,5 +1,6 @@
|
|||
2.16 (?? ??? 2001)
|
||||
- Macro cleanups.
|
||||
- squared_area() and volume() functions added
|
||||
|
||||
2.15 (22 Jan 2001)
|
||||
- CGAL::compare -> CGAL_NTS compare in SphereH3 to fix a warning.
|
||||
|
|
|
|||
|
|
@ -56,8 +56,7 @@ public:
|
|||
bool has_on_bounded_side(const PointH3<FT,RT>& p) const;
|
||||
bool has_on_unbounded_side(const PointH3<FT,RT>& p) const;
|
||||
bool is_degenerate() const;
|
||||
Bbox_2
|
||||
bbox() const;
|
||||
Bbox_2 bbox() const;
|
||||
FT xmin() const;
|
||||
FT ymin() const;
|
||||
FT zmin() const;
|
||||
|
|
@ -65,6 +64,7 @@ public:
|
|||
FT ymax() const;
|
||||
FT zmax() const;
|
||||
|
||||
FT volume() const;
|
||||
|
||||
};
|
||||
|
||||
|
|
@ -193,6 +193,12 @@ FT
|
|||
Iso_cuboidH3<FT,RT>::zmax() const
|
||||
{ return FT( max().hz() ) / FT( max().hw() ); }
|
||||
|
||||
template < class FT, class RT >
|
||||
inline
|
||||
FT
|
||||
Iso_cuboidH3<FT,RT>::volume() const
|
||||
{ return (xmax() - xmin()) * (ymax() - ymin()) * (zmax() - zmin()); }
|
||||
|
||||
template < class FT, class RT >
|
||||
CGAL_KERNEL_LARGE_INLINE
|
||||
PointH3<FT,RT>
|
||||
|
|
@ -224,6 +230,7 @@ PointH3<FT,RT>
|
|||
Iso_cuboidH3<FT,RT>::operator[](int i) const
|
||||
{ return vertex(i); }
|
||||
|
||||
|
||||
template < class FT, class RT >
|
||||
CGAL_KERNEL_MEDIUM_INLINE
|
||||
Bounded_side
|
||||
|
|
|
|||
|
|
@ -70,6 +70,8 @@ public:
|
|||
bool operator==(const TetrahedronH3<FT,RT> &t) const;
|
||||
bool operator!=(const TetrahedronH3<FT,RT> &t) const;
|
||||
Bbox_3 bbox() const;
|
||||
FT volume() const;
|
||||
|
||||
TetrahedronH3<FT,RT>
|
||||
transform(const Aff_transformationH3<FT,RT> &t) const;
|
||||
Orientation orientation() const;
|
||||
|
|
@ -102,7 +104,6 @@ TetrahedronH3<FT,RT>::TetrahedronH3(const PointH3<FT,RT> &p,
|
|||
{}
|
||||
|
||||
|
||||
|
||||
template < class FT, class RT >
|
||||
CGAL_KERNEL_INLINE
|
||||
bool
|
||||
|
|
@ -127,12 +128,12 @@ TetrahedronH3<FT,RT>::operator==(const TetrahedronH3<FT,RT> &t) const
|
|||
return V1 == V2;
|
||||
}
|
||||
|
||||
|
||||
template < class FT, class RT >
|
||||
inline
|
||||
bool
|
||||
TetrahedronH3<FT,RT>::operator!=(const TetrahedronH3<FT,RT> &t) const
|
||||
{ return !(*this == t); }
|
||||
|
||||
template < class FT, class RT >
|
||||
CGAL_KERNEL_INLINE
|
||||
PointH3<FT,RT>
|
||||
|
|
@ -316,6 +317,33 @@ TetrahedronH3<FT,RT>::bbox() const
|
|||
vertex(0).bbox() + vertex(1).bbox() + vertex(2).bbox() + vertex(3).bbox();
|
||||
}
|
||||
|
||||
template < class FT, class RT >
|
||||
CGAL_KERNEL_MEDIUM_INLINE
|
||||
FT
|
||||
TetrahedronH3<FT,RT>::volume() const
|
||||
{
|
||||
VectorH3<FT,RT> vec1 = vertex(1) - vertex(0);
|
||||
VectorH3<FT,RT> vec2 = vertex(2) - vertex(0);
|
||||
VectorH3<FT,RT> vec3 = vertex(3) - vertex(0);
|
||||
|
||||
// first compute (vec1.hw * vec2.hw * vec3.hw * det(vec1, vec2, vec3))
|
||||
// then divide by (6 * vec1.hw * vec2.hw * vec3.hw)
|
||||
FT w123 = vec1.hw() * vec2.hw() * vec3.hw();
|
||||
FT hx1 = vec1.hx();
|
||||
FT hy1 = vec1.hy();
|
||||
FT hz1 = vec1.hz();
|
||||
FT hx2 = vec2.hx();
|
||||
FT hy2 = vec2.hy();
|
||||
FT hz2 = vec2.hz();
|
||||
FT hx3 = vec3.hx();
|
||||
FT hy3 = vec3.hy();
|
||||
FT hz3 = vec3.hz();
|
||||
|
||||
return ( (hx1 * (hy2 * hz3 - hy3 * hz2))
|
||||
- (hy1 * (hx2 * hz3 - hx3 * hz2))
|
||||
+ (hz1 * (hx2 * hy3 - hx3 * hy2)))/ (FT(6) * w123);
|
||||
}
|
||||
|
||||
template < class FT, class RT >
|
||||
inline
|
||||
TetrahedronH3<FT,RT>
|
||||
|
|
@ -323,9 +351,9 @@ TetrahedronH3<FT,RT>::
|
|||
transform(const Aff_transformationH3<FT,RT> &t) const
|
||||
{
|
||||
return TetrahedronH3<FT,RT>(t.transform(vertex(0)),
|
||||
t.transform(vertex(1)),
|
||||
t.transform(vertex(2)),
|
||||
t.transform(vertex(3)));
|
||||
t.transform(vertex(1)),
|
||||
t.transform(vertex(2)),
|
||||
t.transform(vertex(3)));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -56,6 +56,8 @@ public:
|
|||
PointH3<FT,RT> vertex(int i) const;
|
||||
PointH3<FT,RT> operator[](int i) const;
|
||||
|
||||
FT squared_area() const;
|
||||
|
||||
Bbox_3 bbox() const;
|
||||
|
||||
};
|
||||
|
|
@ -109,12 +111,24 @@ TriangleH3<FT,RT>::vertex(int i) const
|
|||
}
|
||||
// return PointH3<FT,RT>();
|
||||
}
|
||||
|
||||
template < class FT, class RT >
|
||||
inline
|
||||
PointH3<FT,RT>
|
||||
TriangleH3<FT,RT>::operator[](int i) const
|
||||
{ return vertex(i); }
|
||||
|
||||
template < class FT, class RT >
|
||||
CGAL_KERNEL_MEDIUM_INLINE
|
||||
FT
|
||||
TriangleH3<FT,RT>::squared_area() const
|
||||
{
|
||||
VectorH3<FT,RT> v1 = vertex(1) - vertex(0);
|
||||
VectorH3<FT,RT> v2 = vertex(2) - vertex(0);
|
||||
VectorH3<FT,RT> v3 = cross_product(v1, v2);
|
||||
return (v3 * v3)/FT(4);
|
||||
}
|
||||
|
||||
template < class FT, class RT >
|
||||
CGAL_KERNEL_INLINE
|
||||
PlaneH3<FT,RT>
|
||||
|
|
|
|||
Loading…
Reference in New Issue