Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Installation/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
Release History
===============

[Release 5.4](https://github.com/CGAL/cgal/releases/tag/v5.4)
-----------

Release date: December 2021

### [2D and 3D Linear Geometry Kernel](https://doc.cgal.org/5.4/Manual/packages.html#PkgKernel23)

- Added `construct_centroid_2_object()` and `compute_determinant_2_object()` in `Projection_traits_xy_3`, `Projection_traits_xz_3`,
and`Projection_traits_yz_3` classes.

[Release 5.3](https://github.com/CGAL/cgal/releases/tag/v5.3)
-----------

Expand Down
66 changes: 66 additions & 0 deletions Kernel_23/include/CGAL/internal/Projection_traits_3.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,63 @@ class Squared_distance_projected_3
}
};

template <class R,int dim>
class Construct_centroid_projected_3
{
public:
typedef typename R::Point_3 Point_3;
typedef typename R::Point_2 Point_2;
typedef typename R::FT RT;
RT x(const Point_3 &p) const { return Projector<R,dim>::x(p); }
RT y(const Point_3 &p) const { return Projector<R,dim>::y(p); }

Point_2 project(const Point_3& p) const
{
return Point_2(x(p), y(p));
}

Point_3 embed(const Point_2& p) const
{
RT coords[3];
coords[Projector<R,dim>::x_index] = p.x();
coords[Projector<R,dim>::y_index] = p.y();
coords[dim] = RT(0);

return Point_3(coords[0], coords[1], coords[2]);
}

Point_3 operator()(const Point_3& p, const Point_3& q, const Point_3& r) const
{
const Point_2 p2(project(p));
const Point_2 q2(project(q));
const Point_2 r2(project(r));
return embed(CGAL::centroid(p2, q2, r2));
}
};

template <class R,int dim>
class Compute_determinant_projected_3
{
public:
typedef typename R::Vector_3 Vector_3;
typedef typename R::Vector_2 Vector_2;
typedef typename R::FT RT;
RT x(const Vector_3 &v) const { return Projector<R,dim>::x(v); }
RT y(const Vector_3 &v) const { return Projector<R,dim>::y(v); }

Vector_2 project(const Vector_3& v) const
{
return Vector_2(x(v), y(v));
}

RT operator()(const Vector_3& v, const Vector_3& w) const
{
const Vector_2 v2(project(v));
const Vector_2 w2(project(w));
return CGAL::determinant(v2, w2);
}
};

template <class R,int dim>
class Intersect_projected_3
{
Expand Down Expand Up @@ -817,6 +874,9 @@ class Projection_traits_3 {
typedef Power_side_of_oriented_power_circle_projected_3<Rp, dim> Power_side_of_oriented_power_circle_2;
typedef Construct_bbox_projected_2<Rp,dim> Construct_bbox_2;

typedef Construct_centroid_projected_3<Rp,dim> Construct_centroid_2;
typedef Compute_determinant_projected_3<Rp,dim> Compute_determinant_2;

typedef typename Rp::Construct_point_3 Construct_point_2;
typedef typename Rp::Construct_weighted_point_3 Construct_weighted_point_2;
typedef typename Rp::Construct_segment_3 Construct_segment_2;
Expand Down Expand Up @@ -1014,6 +1074,12 @@ class Projection_traits_3 {
Construct_bbox_2 construct_bbox_2_object() const
{return Construct_bbox_2();}

Construct_centroid_2 construct_centroid_2_object() const
{return Construct_centroid_2();}

Compute_determinant_2 compute_determinant_2_object() const
{return Compute_determinant_2();}

Compute_scalar_product_2 compute_scalar_product_2_object() const
{return Compute_scalar_product_2();}

Expand Down
8 changes: 8 additions & 0 deletions Kernel_23/test/Kernel_23/test_projection_traits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ int main()

K k;

assert( ( k.construct_centroid_2_object()(p3, q3, r3).x() ==
CGAL::centroid(p2, q2, r2).x() ) &&
( k.construct_centroid_2_object()(p3, q3, r3).y() ==
CGAL::centroid(p2, q2, r2).y() ) );

assert( k.compute_determinant_2_object()(v3, w3) ==
CGAL::determinant(v2, w2) );

assert( k.compute_scalar_product_2_object()(v3, w3) ==
v2 * w2 );

Expand Down