source: tol/tol_pkg/MatQuery/TPP.tol @ dcee251

1941-docker-image-to-testdevel
Last change on this file since dcee251 was dcee251, checked in by Víctor de Buen <vdebuen@…>, 17 years ago

Corregido error en circumcircles

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@1941 be4846ae-f051-483a-831f-b64e7d08527f

  • Property mode set to 100644
File size: 2.9 KB
Line 
1/* -*- mode: C++ -*- */
2//////////////////////////////////////////////////////////////////////////////
3// FILE   : MatQuery.tol
4// PURPOSE: Defines Class @TPP.Delaunay
5//////////////////////////////////////////////////////////////////////////////
6
7//////////////////////////////////////////////////////////////////////////////
8Text _.autodoc.member.TPP.Delaunay =
9"This class is part of the TOL-OOP-API for Triangle++: A Library for Delaunay "
10"2D-Triangulation ";
11Class @TPP.Delaunay
12//////////////////////////////////////////////////////////////////////////////
13{
14  //TPP identifier of internal Delaunay
15  Real _id = ?;
16 
17  ////////////////////////////////////////////////////////////////////////////
18  Static @TPP.Delaunay New(Matrix X)
19  ////////////////////////////////////////////////////////////////////////////
20  {
21    @TPP.Delaunay new = [[
22      Real _.n = Columns(X);
23      Real _.m = Rows(X);
24      Matrix _.X = X;
25      Real _id = TPP.Delaunay.New(_.X) ]]
26  };
27  ////////////////////////////////////////////////////////////////////////////
28  Real __destroy(Real void)
29  ////////////////////////////////////////////////////////////////////////////
30  {
31    If(!IsUnknown(_id) & _id, TPP.Delaunay.Delete(_id));
32    Real _id := 0;
33    True
34  };
35  ////////////////////////////////////////////////////////////////////////////
36  Matrix get.vertices(Real void)
37  ////////////////////////////////////////////////////////////////////////////
38  {
39    TPP.Delaunay.GetVertices(_id)
40  };
41  ////////////////////////////////////////////////////////////////////////////
42  Matrix get.faces.idx(Real void)
43  ////////////////////////////////////////////////////////////////////////////
44  {
45    TPP.Delaunay.GetFaces(_id)
46  };
47  ////////////////////////////////////////////////////////////////////////////
48  Set get.faces(Real void)
49  ////////////////////////////////////////////////////////////////////////////
50  {
51    Matrix faces = TPP.Delaunay.GetFaces(_id);
52    Matrix xy = TPP.Delaunay.GetVertices(_id);
53    Matrix A = SubRow(xy,Col2Set(SubCol(faces,[[1]])));
54    Matrix B = SubRow(xy,Col2Set(SubCol(faces,[[2]])));
55    Matrix C = SubRow(xy,Col2Set(SubCol(faces,[[3]])));
56    [[A,B,C]]
57  };
58  ////////////////////////////////////////////////////////////////////////////
59  Set get.circumcircles(Real void)
60  //http://en.wikipedia.org/wiki/Circumscribed_circle
61  ////////////////////////////////////////////////////////////////////////////
62  {
63    Set faces = get.faces(void);
64    Matrix A = faces::A;
65    Matrix B = faces::B;
66    Matrix C = faces::C;
67    Matrix B_ = B-A;
68    Matrix C_ = C-A;
69    Matrix Bx = SubCol(B_,[[1]]);
70    Matrix By = SubCol(B_,[[2]]);
71    Matrix Cx = SubCol(C_,[[1]]);
72    Matrix Cy = SubCol(C_,[[2]]);
73    Matrix D  = (Bx$*Cy-By$*Cx)*2;
74    Matrix B2 = Bx^2+By^2;
75    Matrix C2 = Cx^2+Cy^2;
76    Matrix Rx = (Cy$*B2-By$*C2)$/D;
77    Matrix Ry = (Bx$*C2-Cx$*B2)$/D;
78    Matrix radius = Sqrt(Rx^2+Ry^2);
79    Matrix center = (Rx|Ry)+A;
80    [[center, radius]]
81  }
82};
83
Note: See TracBrowser for help on using the repository browser.