3D Spherical Geometry Kernel( Geometry Kernels) CGAL 4.13 -User Manual

Introduction

The goal of the 3D spherical kernel is to offer to the user a large set of functionalities on spheres, circles and circular arcs, in the 3D space or restricted on a given sphere. These functionalities require computing on algebraic numbers, which motivates the creation of a new kernel concept extending the CGAL Kernel concept, that is restricted to objects and functionality in a FieldNumberType.html

All the choices (interface, robustness, representation, and so on) made here are consistent with the choices made in the CGAL kernel, for which we refer the user to the 2D and 3D Linear Kernel).app

3D spherical kernel 的目標是給用戶提供3D空間或嚴格地在給定球上的一套大量的面向球體、圓和圓弧的功能函數。這引發功能函數要求代數數的計算,激發了由概念CGAL Kernel擴展而建立一個新的內核,這個內核嚴格地使用基於FieldNumberType的對象和函數。less

Spherical Kernel Objects

New main geometric objects are introduced by Spherical_kernel_3: circular arcs ((model of SphericalKernel::CircularArc_3), points of circular arcs (model of SphericalKernel::CircularArcPoint_3), and line segments (model of SphericalKernel::LineArc_3) whose endpoints are points of this new type.dom

SphericalKernel::CircularArcPoint_3 is used in particular for endpoints of arcs and intersection points between spheres, circles or arcs. The coordinates of these points are algebraic numbers of degree two. Therefore, general predicates offered by the Kernel on Point_3, which have coordinates in a FieldNumberType, would require heavy algebraic computations in algebraic extensions of higher degrees and thus are not provided on them, which explains the need for a new point type.ide

A consistent set of predicates and constructions is offered on these new types.函數

新的主幾何對象由Spherical_kernel_3引入:圓弧((SphericalKernel::CircularArc_3概念的模型),圓弧上的點(SphericalKernel::CircularArcPoint_3概念的模型,和線段),線段(SphericalKernel::LineArc_3的模型)它的端點是是圓弧上的點)。ui

是特別用於圓弧的端點和球體、圓或弧的交集。這些點的座標是2級代數數(algebraic numbers of degree two)。因此,本Kernel提供的面向 Point_3的通用斷定(具備FieldNumberType類型座標)在代數擴展到較高維度的狀況下須要進行高強度的代數計算於是沒有被提供,which explains the need for a new point type。this

一個面向這一新類型的一致的斷定和構造集合由本包提供。spa

 

General Functionalitiesprototype

The spherical kernel currently implements a set of fundamental functionalities like intersection, comparisons, inclusion, etc. More might be provided in the future, as long as only algebraic numbers of degree two are used.

spherical kernel當前提供了一個基本函數集的實現:交集(intersection),比較(comparisons),包含(inclusion)等。更多的功能新在將來提供。

Functionalities Relative to a Sphere

The interface of the underlying objects is extended by providing additional operations that make sense only if the objects are considered on the same sphere. For example, the result of the comparison of the cylindrical or spherical coordinates of two points is well-defined only when looking at them on a given common sphere. The presentation of these operations requires the following definitions:

Coordinate system. Let consider a sphere with center c and radius r. Using the Cartesian frame centered at c, we define a cylindrical coordinate system (θ,z) on that sphere, with θ[0,2π) and z[r,r]θ is given in radian and measured in the xy-plane around the z-axis, starting from x>0y=0. The z-extremal points of a sphere are its North and South poles defined as (θ,r) and (θ,r) respectively, for any value of θ. Observe that each point on the sphere different from a pole corresponds to a unique pair (θ,z).

Definition of a meridian. Given a sphere and its associated cylindrical coordinate system, a meridian of that sphere is a circular arc consisting of the points having the same theta-coordinate (the poles are the end points). A plane containing the two poles of that sphere defines two meridians, one on each side of the line passing through the poles. A vector M whose direction is different from that of the latter line defines a unique meridian on that sphere. The plane of that meridian is defined by the direction of M and the two poles. The sense of M disambiguates the choice among the pair of meridians thus defined. On Figure 11.1, the normal vectors n0 and n1define two meridians of S: the circular arcs A0 and A1 respectively.

下層對象的接口提供了附加的操做,這些操做只有在對象是同一個球體時纔有效。如,2個柱面或球面的點的座標的比較結果是良好定義的,當且僅當將兩個點放在一個給定的共同球上。這些操做的使用須要下面的定義:

座標系統(Coordinate system。咱們考慮一個球體,其圓心是c 半徑是 r。使用笛卡爾座標並將其中心定爲 c,咱們在球上定義柱面座標系統(θ,z),其中 θ[0,2π) 且 z[r,r]。θ由弧度給出且在xy面上上圍繞z軸測定(由x>0, y=0起始)。 球的z極點分別是其北極 (θ,r)和南極點(θ,r)。對於任意的角度 θ(即θ固定時). 觀察球面上每一個點的不一樣在於惟一的對(θ,z)肯定的極。

子午線定義(Definition of a meridian.。給定一個球體和它相應的柱面座標系統,球的一個子午線是一個包含了全部相同 θ 的點的一個圓弧(極點是其端點)。一個包含兩極的平面定義了兩個子午線,分別在兩個極點連線的兩側。

一個向量M,其方向與前面定義的直線方向不一樣,它定義了惟一的球體子午線。子午線所在平面由M的方向和兩個極點肯定。M的定義消除了在選擇兩個子午線時的歧義。在圖11.1中,正定(mormal) 的向量n0和n1定義了S的兩個子午線:分別是圓弧A0和A1。

 

 

def_meridian.png
Figure 11.1 Definition of two meridians on  S, a sphere of center c. The intersection of the plane P (passing through the two poles of S) and the sphere S is a circle. The two poles of S split that circle into two circular arcs A0 and A1, each being a meridian of S. The θ-coordinates of meridians A0 and A1 are θ0 and θ1=θ0+π respectively.

Types of circles on a sphere. Given a sphere, a circle on that sphere is termed polar if it goes through only one pole, bipolar if it goes through the two poles of that sphere and threaded if it separates the sphere into two connected components, each containing one pole. Any other circle is termed normal. These definitions are illustrated on Figure 11.2.

圖11.1定義了S球體的兩個子午線。經過S兩個極點的平面P和S的交集是一個圓。A0和A1分別是S的兩個子午線,它們由兩個極點分開。這兩個子午線的θ座標分別是θ0 和 θ1=θ0+π。

球上的圓的類型(types of circles on a sphere)。若是一個圓只經過一個極點,則被稱爲極圓(polar );若是它經過兩個極點,則爲雙極圓(bipolar )。若是它將球體分割爲兩個鏈接的部分,每一個部分包含一個極點,則爲間線圓(threaded );其餘全部的圓被稱爲普通線(normal)。圖11.2給出了幾種線。

 

def_circles_extreme_pt.png
Figure 11.2 The four types of circles on a sphere. Black dots are the  θ-extremal points.

θ-extremal points. Given a sphere one has: a θ-extremal point of a normal circle is a point of tangency between the circle and a meridian anchored at the poles of that sphere. Each normal circle defines two such points; the θ-extremal point of a polar circle is the pole the circle goes through. No such point is defined on a bipolar or a threaded circle. These definitions are illustrated on Figure 11.2. Notice that the θ-extremal points should not be confused with the endpoints of an arbitrary arc on a sphere.

The θ-coordinate of a θ-extremal point of a normal circle on a sphere is well defined. For a polar circle on a sphere, the plane containing the two poles and which is tangent to that circle contains two different meridians. The θ-values of these meridians are the two θ-coordinates associated to the same θ-extremal point of a polar circle.

θ-monotone circular arcs. An arc on a sphere is said to be θ-monotone if any meridian on that sphere intersects that arc in at most one point. With this definition, a circular arc on a threaded circle is always θ-monotone, and an arc on a polar or normal circle is θ-monotone if it does not contain a θ-extremal point, unless it is an endpoint. No such arc is defined on a bipolar circle.

θ-外部點(θ-extremal points.。給定一個球體,它有:一個普通圓的θ-外部點是該圓與一個子午線之間的切點。每一個普通圓定義了兩個這樣的點;極圓(polar )的θ-外部點是該圓所經的極點。雙極圓和間線圓(threaded )沒有這個點定義。注意:不要將θ-外部點(θ-extremal points.)與球上的一個弧的端點相混淆。

一個普通圓(normal circleθ-外部點(θ-extremal points.)的θ-座標(θ-coordinate)是定義良好的。對一個球上極圓(polar ),與其相切、且過兩極的的平面包含兩個子午線。這兩個子午線的θ-座標值就是這個單θ-外部點的兩個θ-座標。

θ-單調圓弧θ-monotone circular arcs. )若是一個球上的全部子午線與一個弧最多隻有一個交點,則咱們說這個弧是θ-單調圓弧。基於這必定義 ,咱們發現全部 間線圓是θ-單調圓弧,而若是一個極圓(polar )或一個普通圓上的弧若是不含θ-外部點則它是θ-單調圓弧,除非它是一個端點。在雙極圓上則沒有θ-單調圓弧的概念定義。

 

Software Design

The design of Spherical_kernel_3 is similar to the design of Circular_kernel_2 (see Chapter 2D Circular Geometry Kernel).

It has two template parameters:

  • the first parameter must model the CGAL three dimensional Kernel concept. The spherical kernel derives from it, and it provides all elementary geometric objects like points, lines, spheres, circles and elementary functionality on them.
  • the second parameter is the algebraic kernel, which is responsible for computations on polynomials and algebraic numbers. It must model the concept AlgebraicKernelForSpheres. The robustness of the package relies on the fact that the algebraic kernel provides exact computations on algebraic objects.

The 3D spherical kernel uses the extensibility scheme presented in the kernel manual (see Section Extensible Kernel). The types of Kernel are inherited by the 3D spherical kernel and some types are taken from the AlgebraicKernelForSpheres parameter. Spherical_kernel_3 introduces new geometric objects as mentioned in Section Spherical Kernel Objects.

In fact, the spherical kernel is documented as a concept, SphericalKernel and two models are provided:

Spherical_kernel_3定義與的 Circular_kernel_2定義類似(see Chapter 2D Circular Geometry Kernel)。

它有兩個模板參數:

  第一個參數必須是CGAL 3D  Kernel 概念的一個模型。spherical kernel 由它繼承而來,它提供了全部基本的幾何對象,如點,線,球體,圓和操做這些對象的基本的函數。

  第二個參數是代數內核(algebraic kernel),負責計算多項式和代數數。它必須是 AlgebraicKernelForSpheres概念的模型。本包的健壯性依賴於代數內核提供對代數對象的精確的計算。

3D spherical kernel 使用 kernel 手冊中給出的可擴展模型((see Section Extensible Kerne)。3D spherical kernel繼承了 Kernel 的類型,且有些類型取自於AlgebraicKernelForSpheres參數。Spherical_kernel_3 引入Spherical Kernel Objects一藬中提到的新的幾何對象。

實際上,spherical kerne被載明是一個概念,其中提供SphericalKernel和兩個模型:

  (1)Spherical_kernel_3<Kernel,AlgebraicKernelForSpheres>,即基本模型

  (2)一個預先定義的內核:Exact_spherical_kernel_3

 

Examples

The first example shows how to construct spheres and compute intersections on them using the global function.

第一個例子演示如何使用全局函數構造球體並計算它們的交集


File Circular_kernel_3/intersecting_spheres.cpp

#include <CGAL/Exact_spherical_kernel_3.h>
#include <CGAL/Random.h>
 
typedef CGAL::Exact_spherical_kernel_3 Spherical_k;
 
typedef CGAL::Point_3<Spherical_k> Point_3;
typedef CGAL::Sphere_3<Spherical_k> Sphere_3;
 
int main() {
 
CGAL::Random generatorOfgenerator;
int random_seed = generatorOfgenerator.get_int(0, 123456);
CGAL::Random theRandom(random_seed);
int count = 0;
 
std::cout << "We will compute the approximate probability that 3 spheres wit"
<< "h radius 1 intersect on a 5x5x5 box, it might take some time." << std::endl;
 
for(int i=0; i<10000; i++) {
 
double x1 = theRandom.get_double(0.0,5.0);
double y1 = theRandom.get_double(0.0,5.0);
double z1 = theRandom.get_double(0.0,5.0);
double r = 1.0;
double x2 = theRandom.get_double(0.0,5.0);
double y2 = theRandom.get_double(0.0,5.0);
double z2 = theRandom.get_double(0.0,5.0);
double x3 = theRandom.get_double(0.0,5.0);
double y3 = theRandom.get_double(0.0,5.0);
double z3 = theRandom.get_double(0.0,5.0);
 
Sphere_3 s1 = Sphere_3(Point_3(x1,y1,z1), r);
Sphere_3 s2 = Sphere_3(Point_3(x2,y2,z2), r);
Sphere_3 s3 = Sphere_3(Point_3(x3,y3,z3), r);
 
std::vector< CGAL::Object > intersecs;
CGAL::intersection(s1, s2, s3, std::back_inserter(intersecs));
if(intersecs.size() > 0) count++;
}
 
std::cout << "The approximate probability that 3 spheres with radius 1"
<< std::endl;
std::cout << "choosen (uniformly) randomly on a 5x5x5 box intersect is: "
<< ((double)count)/((double)(10000)) << std::endl;
 
return 0;
}
 
 

The second example illustrates the use of a functor.

第二個例子演示函子的使用。


File Circular_kernel_3/functor_has_on_3.cpp

#include <CGAL/Exact_spherical_kernel_3.h>
#include <CGAL/Random.h>
 
typedef CGAL::Exact_spherical_kernel_3 Spherical_k;
 
typedef CGAL::Point_3<Spherical_k> Point_3;
typedef CGAL::Circular_arc_3<Spherical_k> Circular_arc_3;
 
int main()
{
int n = 0;
Circular_arc_3 c = Circular_arc_3(Point_3(10,10,0), Point_3(5,5,5), Point_3(0, 0, 0));
for(int i = 0; i <= 10; i++) {
for(int j = 0; j <= 10; j++) {
for(int k = 0; k <= 10; k++) {
Point_3 p = Point_3(i, j, k);
if(Spherical_k().has_on_3_object()(c,p)) {
n++;
std::cout << "(" << i << "," << j << "," << k << ")" << std::endl;
}
}
}
}
 
std::cout << "There are " << n << " points in the "
<< "[0,..,10]x[0,..,10]x[0,...,10] "
<< "grid on the circular" << std::endl
<< " arc defined by the points (10,10,0), (5,5,5), (0,0,0)"
<< std::endl << "See the points above." << std::endl;
return 0;
}
 
 

The third example illustrates the use of a functor on objects on the same sphere. The intersection points of two circles on the same sphere are computed and their cylindrical coordinates are then compared.

第三個例子演示在同一個球體上的對象上使用函子。計算同一個球體上的兩個弧的交點並比較它們的柱面座標。


File Circular_kernel_3/functor_compare_theta_3.cpp

#include <CGAL/Exact_spherical_kernel_3.h>
 
 
int main(){
//construction of 3 spheres from their centers and squared radii
SK::Sphere_3 s1(SK::Point_3(0,0,0),2);
SK::Sphere_3 s2(SK::Point_3(0,1,0),1);
SK::Sphere_3 s3(SK::Point_3(1,0,0),3);
 
//construct two circles lying on sphere s1
SK::Circle_3 C1(s1,s2);
SK::Circle_3 C2(s1,s3);
 
SK::Intersect_3 inter;
//create a functor to compare theta-coordinates on sphere s1
SK::Compare_theta_z_3 cmp(s1);
std::vector< CGAL::Object > intersections;
inter(C1,C2,std::back_inserter(intersections));
 
//unsigned integer indicates multiplicity of intersection point
std::pair<SK::Circular_arc_point_3,unsigned> p1=
CGAL::object_cast< std::pair<SK::Circular_arc_point_3,unsigned> >(intersections[0]);
std::pair<SK::Circular_arc_point_3,unsigned> p2=
CGAL::object_cast< std::pair<SK::Circular_arc_point_3,unsigned> >(intersections[1]);
 
 
SK::Circular_arc_point_3 t_extreme[2];
//Compute theta extremal points of circle C1 on sphere s1
CGAL::theta_extremal_points(C1,s1,t_extreme);
 
//The theta coordinates of theta extremal points of C1 enclose that of each intersection point.
assert(cmp(t_extreme[0],p1.first)== CGAL::SMALLER);
assert(cmp(t_extreme[0],p2.first)== CGAL::SMALLER);
assert(cmp(t_extreme[1],p1.first)== CGAL::LARGER);
assert(cmp(t_extreme[1],p2.first)== CGAL::LARGER);
 
return 0;
}

Design and Implementation History

This package follows the design of the package 2D Circular Geometry Kernel).

Julien Hazebrouck and Damien Leroy participated in a first prototype.

The first version of the package was co-authored by Pedro Machado Manhães de Castro and Monique Teillaud, and integrated in CGAL 3.4. Frédéric Cazals and Sébastien Loriot extended the package by providing functionalities restricted on a given sphere [1].

Sylvain Pion is acknowledged for helpful discussions.

This work was partially supported by the IST Programme of the 6th Framework Programme of the EU as a STREP (FET Open Scheme) Project under Contract No IST-006413 (ACS - Algorithms for Complex Shapes).

相關文章
相關標籤/搜索