CGAL / cgal

The public CGAL repository, see the README below
https://github.com/CGAL/cgal#readme
Other
4.85k stars 1.38k forks source link

Plane_3 X and Y axis and origin #5962

Closed petrasvestartas closed 2 years ago

petrasvestartas commented 3 years ago

I am using following plane definition

using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel; using Plane = Kernel::Plane_3; https://doc.cgal.org/latest/Kernel_23/classCGAL_1_1Plane__3.html

Issue Details

I cannot find any properties how Plane_3 defines its orientation considering x and y axis and position.

Are there any other plane data-structures in CGAL that has origin point and x and y vectors for a plane. Because it is hard to know the orientation of a plane besides the z normal.

image

PaulXiCao commented 2 years ago

I believe this issue to be off-topic and better suited for another forum (maybe [https://stackoverflow.com/questions/tagged/cgal stackoverflow-cgal]?). Nonetheless, I will try to answer your questions.


its orientation considering x and y axis and position.

Can you state your question more clearly? Are you talking about intersection points with the x- and y-axis?

I am not sure if that helps but obviously planes can be defined in multiple ways which is why there are multiple constructors, i.e.

origin point and x and y vectors for a plane.

You want to construct a plane via an intersection point and two non-parallel vectors pointing along the plane? There is a constructor using an intersection point and the orthogonal vector. Note, that the orthogonal vector can be computed using the cross-product.

petrasvestartas commented 2 years ago

Dear @PaulXiCao ,

Thanks for the answer. Before closing this issue, I would like to ask if, is it possible to have at least origin point of CGAL plane? Or Plane_3 just gives plane orientation as a mathematical model without origin.

Below is what I in the end ported. It was not easy, because axial representation requires some ugly checks. But in case somebody would like to use it, solution is below.

I really wish that CGAL documentation would be richer visually for the basic geometry types or at least have better descriptions. There are good descriptions for algorithms, but for primitive types it is a bit sparse (sorry for negativity, it was a long week to make this stuff work.)

////////////////////////////////////////SOLUTION BELOW//////////////////////////////////////// If someone will have similar issue here is a ported version from OpenNurbs for CGAL, PlaneAxis.zip attached. Files AxisPlane.cpp and AxisPlane.h PlaneAxis.zip

To make it work you need to define these types:

static double GlobalTolerance = 0.01;
static double GlobalClipperScale = 10000.0;
static double GlobalClipperAreaTolerance = 0.0001;
#define ON_IS_FINITE(x) (0x7FF0 != (*((unsigned short*)(&x) + 3) & 0x7FF0))
#define ON_DBL_MIN 2.22507385850720200e-308
#define ON_EPSILON 2.2204460492503131e-16
#define ON_SQRT_EPSILON 1.490116119385000000e-8
#define ON_ZERO_TOLERANCE 2.3283064365386962890625e-10

using CGAL_Kernel = CGAL::Exact_predicates_inexact_constructions_kernel;
using CGAL_Point = CGAL_Kernel::Point_3;
using CGAL_Direction = CGAL_Kernel::Direction_3;
using CGAL_Vector = CGAL_Kernel::Vector_3;
using CGAL_Vector2 = CGAL_Kernel::Vector_2;
using CGAL_Plane = CGAL_Kernel::Plane_3;
using CGAL_BBox = CGAL::Bbox_3;
using CGAL_Polyline = std::vector<CGAL_Kernel::Point_3>;
using CGAL_Polylines = std::list<CGAL_Polyline>;
using CGAL_Transformation = CGAL::Aff_transformation_3<CGAL_Kernel>;
using CGAL_Line = CGAL_Kernel::Line_3;