chart.h
Go to the documentation of this file.
1 #ifndef CHARTH
2 #define CHARTH
3 
4 #include "boolean.h"
5 #include "parameters.h"
6 #include "cpolytope.h"
7 #include "scpolytope.h"
8 #include "jacobian.h"
9 
10 #include "plot3d.h"
11 
12 #include "geom.h"
13 
14 #include "cuiksystem.h"
15 #include "world.h"
16 
40 #define PLOT_ON_MANIFOLD 0
41 
50 #define PLOT_AS_POLYGONS 1
51 
52 
59 #define MIN_SAMPLING_RADIUS 1e-3
60 
70 typedef struct {
71  /* The chart information */
73  unsigned int m;
74  unsigned int k;
75  unsigned int n;
76  unsigned int nrJ;
79  double error;
80  double eCurv;
81  double r;
83  unsigned int degree;
84  boolean collision;
85  boolean frontier;
88  boolean singular;
92  double *center;
93  double *T;
95  boolean *BJ;
99  unsigned int ml;
102  unsigned int nl;
103  unsigned int *l;
105  /* Polytope information (can be full or simple) */
106  boolean simple;
109 } Tchart;
110 
142 unsigned int InitChart(Tparameters *pr,boolean simple,Tbox *domain,unsigned int *tp,
143  unsigned int m,unsigned int k,double *p,double e, double eCurv,double r,
144  TJacobian *sJ,TAtlasBase *w,
145  Tchart *c);
175 unsigned int InitPossiblySingularChart(Tparameters *pr,boolean simple,Tbox *domain,unsigned int *tp,
176  unsigned int m,unsigned int k,double *p,double e, double eCurv,double r,
177  TJacobian *sJ,TAtlasBase *w,
178  Tchart *c);
179 
208 unsigned int InitSingularChart(Tparameters *pr,boolean simple,Tbox *domain,unsigned int *tp,
209  unsigned int m,unsigned int k,double *p,double e, double eCurv,double r,
210  TJacobian *sJ,TAtlasBase *w,
211  Tchart *c);
212 
241 unsigned int InitTrustedChart(Tparameters *pr,boolean simple,Tbox *domain,unsigned int *tp,
242  unsigned int m,unsigned int k,double *p,double e, double eCurv,double r,
243  TJacobian *sJ,TAtlasBase *w,
244  Tchart *c);
245 
278 unsigned int InitChartWithTangent(Tparameters *pr,boolean simple,Tbox *domain,unsigned int *tp,
279  unsigned int m,unsigned int k,double *p,double *T,
280  double e, double eCurv, double r,TJacobian *sJ,
281  TAtlasBase *w,Tchart *c);
282 
291 void CopyChart(Tchart *c_dst,Tchart *c_src);
292 
310 boolean CompareTangentSpaces(Tchart *c1,Tchart *c2);
311 
324 double MinCosinusBetweenCharts(Tchart *c1,Tchart *c2);
325 
340 
350 double *GetChartCenter(Tchart *c);
351 
361 double GetChartRadius(Tchart *c);
362 
375 double GetChartSamplingRadius(Tchart *c);
376 
386 double GetChartMaxError(Tchart *c);
387 
397 double GetChartMaxCurvError(Tchart *c);
398 
399 
409 unsigned int GetChartAmbientDim(Tchart *c);
410 
420 unsigned int GetChartManifoldDim(Tchart *c);
421 
432 double *GetChartTangentSpace(Tchart *c);
433 
444 boolean SingularChart(Tchart *c);
445 
457 boolean *GetChartJacobianBasis(Tchart *c);
458 
499 unsigned int GetChartDegree(Tparameters *pr,double *T,TJacobian *sJ,
500  boolean *singular,Tchart *c);
501 
538 double Manifold2Chart(double *p,unsigned int *tp,double *t,Tchart *c);
539 
578 double Chart2Manifold(Tparameters *pr,TJacobian *sJ,
579  double *t,unsigned int *tp,double *pInit,
580  double *p,Tchart *c);
581 
582 
594 void Local2Global(double *t,unsigned int *tp,double *p,Tchart *c);
595 
615 double ChartErrorFromParameters(double *t,double *p,
616  unsigned int *tp,Tchart *c);
617 
633 double Error2Chart(double *p,unsigned int *tp,Tchart *c);
634 
648 boolean CloseCharts(Tparameters *pr,unsigned int *tp,
649  Tchart *c1,Tchart *c2);
650 
667 boolean IntersectCharts(Tparameters *pr,unsigned int *tp,Tbox *ambient,
668  unsigned int id1,Tchart *c1,
669  unsigned int id2,Tchart *c2);
670 
671 
681 boolean CollisionChart(Tchart *c);
682 
692 boolean FrontierChart(Tchart *c);
693 
702 void ChartIsFrontier(Tchart *c);
703 
718 boolean ExpandibleChart(Tchart *c);
719 
738 boolean OpenChart(Tchart *c);
739 
748 void WrongCorner(unsigned int nv,Tchart *c);
749 
750 
762 boolean InsideChartPolytope(double *t,Tchart *c);
763 
776 unsigned int DetermineChartNeighbour(double epsilon,double *t,Tchart *c);
777 
792 void EnlargeChart(double *t,Tchart *c);
793 
809 boolean BoundaryPointFromExternalCorner(boolean rand,unsigned int *nv,double *t,Tchart *c);
810 
827 void BoundaryPointsFromExternalCorners(unsigned int *n,unsigned int **nv,double ***t,Tchart *c);
828 
839 boolean RandomPointOnBoundary(double *t,Tchart *c);
840 
864 boolean RandomPointInChart(Tparameters *pr,double scale,
865  unsigned int *tp,double *t,double *p,Tchart *c);
866 
875 
884 
898 double ChartMaxVolume(Tchart *c);
899 
922 double ChartVolume(Tparameters *pr,boolean collisionFree,
923  unsigned int *tp,TJacobian *sJ,Tchart *c);
924 
939 boolean FocusedPointOnBoundary(double *p,unsigned int *tp,double *t,Tchart *c);
940 
941 
971 boolean PathInChart(Tparameters *pr,double *t,unsigned int *tp,TJacobian *sJ,
972  unsigned int nvs,boolean *systemVars,
973  unsigned int *ms,
974  double *pl,unsigned int *ns,double ***path,
975  Tchart *c);
976 
992 double DistanceOnChart(Tparameters *pr,double *t,unsigned int *tp,TJacobian *sJ,
993  Tchart *c);
994 
1010 boolean PointOnChart(Tparameters *pr,TJacobian *sJ,
1011  double *p,unsigned int *tp,
1012  double *t,Tchart *c);
1013 
1045 unsigned int ClassifyPointInChart(Tparameters *pr,boolean error,TJacobian *sJ,
1046  double *p,unsigned int *tp,
1047  double *t,Tchart *c);
1069 void LinkCharts(unsigned int id1,Tchart *c1,unsigned int id2,Tchart *c2);
1070 
1084 void AddBorderConstraint(Tparameters *pr,double *t,unsigned int *tp,Tbox *ambient,Tchart *c);
1085 
1103 void ForceChartCut(Tparameters *pr,unsigned int *tp,Tbox *ambient,
1104  unsigned int id1,Tchart *c1,
1105  unsigned int id2,Tchart *c2) ;
1106 
1121 unsigned int ChartNumNeighbours(Tchart *c);
1122 
1138 unsigned int ChartNeighbourID(unsigned int n,Tchart *c);
1139 
1165  unsigned int *nn,unsigned int **cID1,unsigned int **cID2,Tchart *c);
1166 
1202 void PlotChart(Tparameters *pr,FILE *fcost,TJacobian *sJ,
1203  unsigned int xID,unsigned int yID,unsigned int zID,
1204  Tplot3d *p3d,Tchart *c);
1205 
1215 unsigned int ChartMemSize(Tchart *c);
1216 
1225 void SaveChart(FILE *f,Tchart *c);
1226 
1237 void LoadChart(FILE *f,TAtlasBase *w,Tchart *c);
1238 
1246 void DeleteChart(Tchart *c);
1247 
1248 #endif
Definition of the boolean type.
unsigned int k
Definition: chart.h:74
Tcpolytope * p
Definition: chart.h:107
boolean FocusedPointOnBoundary(double *p, unsigned int *tp, double *t, Tchart *c)
Generates point on the boundary towards a given goal.
Definition: chart.c:1458
void ForceChartCut(Tparameters *pr, unsigned int *tp, Tbox *ambient, unsigned int id1, Tchart *c1, unsigned int id2, Tchart *c2)
Intersect two charts that might be non-neighbours.
Definition: chart.c:265
void EnlargeChart(double *t, Tchart *c)
Ensures that a chart includes a given point.
Definition: chart.c:1332
Definition of basic functions.
double Chart2Manifold(Tparameters *pr, TJacobian *sJ, double *t, unsigned int *tp, double *pInit, double *p, Tchart *c)
Returns the point in the manifold for a given set of parameteres.
Definition: chart.c:1066
double error
Definition: chart.h:79
void ChartIsFrontier(Tchart *c)
Marks a chart as a frontier chart.
Definition: chart.c:1287
unsigned int GetChartManifoldDim(Tchart *c)
Dimensionality of the manifold space.
Definition: chart.c:965
boolean RandomPointInChart(Tparameters *pr, double scale, unsigned int *tp, double *t, double *p, Tchart *c)
Samples a random point in the area covered by the chart.
Definition: chart.c:1364
unsigned int * l
Definition: chart.h:103
double GetChartSamplingRadius(Tchart *c)
Returns de sampling range of the chart.
Definition: chart.c:943
void LoadChart(FILE *f, TAtlasBase *w, Tchart *c)
Defines a chart from the information on a file.
Definition: chart.c:1932
boolean collision
Definition: chart.h:84
boolean simple
Definition: chart.h:106
Definition of the TJacobian type and the associated functions.
double Error2Chart(double *p, unsigned int *tp, Tchart *c)
Distance from the manifold to the tangent space.
Definition: chart.c:1247
void DeleteChart(Tchart *c)
Destructor.
Definition: chart.c:2011
unsigned int InitTrustedChart(Tparameters *pr, boolean simple, Tbox *domain, unsigned int *tp, unsigned int m, unsigned int k, double *p, double e, double eCurv, double r, TJacobian *sJ, TAtlasBase *w, Tchart *c)
Constructor.
Definition: chart.c:816
unsigned int InitChart(Tparameters *pr, boolean simple, Tbox *domain, unsigned int *tp, unsigned int m, unsigned int k, double *p, double e, double eCurv, double r, TJacobian *sJ, TAtlasBase *w, Tchart *c)
Constructor.
Definition: chart.c:792
unsigned int ChartNeighbourID(unsigned int n, Tchart *c)
Returns the identifier of one of the neighbours of a chart.
Definition: chart.c:1687
Definition of the Tplot3d type and the associated functions.
boolean CollisionChart(Tchart *c)
Identifies collision charts.
Definition: chart.c:1277
boolean * BJ
Definition: chart.h:95
boolean RandomPointOnBoundary(double *t, Tchart *c)
Random point on the boundary of the chart.
Definition: chart.c:1356
unsigned int GetChartDegree(Tparameters *pr, double *T, TJacobian *sJ, boolean *singular, Tchart *c)
Returns the chart degree.
Definition: chart.c:985
double DistanceOnChart(Tparameters *pr, double *t, unsigned int *tp, TJacobian *sJ, Tchart *c)
Distance between the center of a chart and a point on this chart.
Definition: chart.c:1546
unsigned int GetChartAmbientDim(Tchart *c)
Dimensionality of the ambient space.
Definition: chart.c:960
void DecreaseChartSamplingRadius(Tchart *c)
Decrease the sampling radious of the chart.
Definition: chart.c:1385
Definition of a polytope associated to a chart.
A chart on a manifold.
Definition: chart.h:70
boolean SingularChart(Tchart *c)
Identify charts defined on singularities.
Definition: chart.c:980
Definition of the Tworld type and the associated functions.
boolean CloseCharts(Tparameters *pr, unsigned int *tp, Tchart *c1, Tchart *c2)
Identifies close local charts.
Definition: chart.c:1264
void WrongCorner(unsigned int nv, Tchart *c)
Mark a vertex as wrong.
Definition: chart.c:1305
unsigned int ChartNumNeighbours(Tchart *c)
Number of neighbours of the chart.
Definition: chart.c:1675
A 3D plot.
Definition: plot3d.h:54
unsigned int InitChartWithTangent(Tparameters *pr, boolean simple, Tbox *domain, unsigned int *tp, unsigned int m, unsigned int k, double *p, double *T, double e, double eCurv, double r, TJacobian *sJ, TAtlasBase *w, Tchart *c)
Constructor.
Definition: chart.c:824
void CopyChart(Tchart *c_dst, Tchart *c_src)
Copy constructor.
Definition: chart.c:833
A simpleifed polytope associated with chart on a manifold.
Definition: scpolytope.h:61
double * GetChartCenter(Tchart *c)
Returns the center of the chart.
Definition: chart.c:933
double * T
Definition: chart.h:93
double GetChartMaxError(Tchart *c)
Returns the maximum error between the chart and the manifold.
Definition: chart.c:950
double r
Definition: chart.h:81
double MinCosinusBetweenCharts(Tchart *c1, Tchart *c2)
Computes the angle between the tangent spaces in the charts.
Definition: chart.c:920
unsigned int degree
Definition: chart.h:83
unsigned int ml
Definition: chart.h:99
boolean OpenChart(Tchart *c)
Identifies charts not fully sorrounded by other charts.
Definition: chart.c:1300
double Manifold2Chart(double *p, unsigned int *tp, double *t, Tchart *c)
Returns the parametrization of a point.
Definition: chart.c:1036
boolean BoundaryPointFromExternalCorner(boolean rand, unsigned int *nv, double *t, Tchart *c)
Random point on the chart boundary from the polytope vetices.
Definition: chart.c:1340
double ChartMaxVolume(Tchart *c)
Estimate the volume of a chart.
Definition: chart.c:1391
boolean * GetChartJacobianBasis(Tchart *c)
Gets the index of the basis of the Jacobian vectors forming a basis.
Definition: chart.c:975
unsigned int m
Definition: chart.h:73
A table of parameters.
Definition of the TCuikSystem type and the associated functions.
unsigned int InitSingularChart(Tparameters *pr, boolean simple, Tbox *domain, unsigned int *tp, unsigned int m, unsigned int k, double *p, double e, double eCurv, double r, TJacobian *sJ, TAtlasBase *w, Tchart *c)
Constructor.
Definition: chart.c:808
unsigned int InitPossiblySingularChart(Tparameters *pr, boolean simple, Tbox *domain, unsigned int *tp, unsigned int m, unsigned int k, double *p, double e, double eCurv, double r, TJacobian *sJ, TAtlasBase *w, Tchart *c)
Constructor.
Definition: chart.c:800
unsigned int nrJ
Definition: chart.h:76
double * center
Definition: chart.h:92
unsigned int DetermineChartNeighbour(double epsilon, double *t, Tchart *c)
Determines the neighbouring chart containing a given point.
Definition: chart.c:1321
boolean singular
Definition: chart.h:88
Type defining the equations on which the atlas is defined.
Definition: wcs.h:30
void LinkCharts(unsigned int id1, Tchart *c1, unsigned int id2, Tchart *c2)
Connect charts at singularities.
Definition: chart.c:1669
TAtlasBase * w
Definition: chart.h:72
double GetChartMaxCurvError(Tchart *c)
Returns the maximum oriented curvature error between the chart and the manifold.
Definition: chart.c:955
boolean PointOnChart(Tparameters *pr, TJacobian *sJ, double *p, unsigned int *tp, double *t, Tchart *c)
Identify points on a chart.
Definition: chart.c:1602
void PlotChart(Tparameters *pr, FILE *fcost, TJacobian *sJ, unsigned int xID, unsigned int yID, unsigned int zID, Tplot3d *p3d, Tchart *c)
Plots a 3d projection of a local chart.
Definition: chart.c:1726
unsigned int nl
Definition: chart.h:102
unsigned int ChartMemSize(Tchart *c)
Memory used by a given chart.
Definition: chart.c:1862
void BoundaryPointsFromExternalCorners(unsigned int *n, unsigned int **nv, double ***t, Tchart *c)
All the possible points on the chart's boundary from polytope vertices.
Definition: chart.c:1348
A box.
Definition: box.h:83
Definition of a smple polytope associated to a chart.
boolean CompareTangentSpaces(Tchart *c1, Tchart *c2)
Checks if the tangent spaces are similar.
Definition: chart.c:901
boolean PathInChart(Tparameters *pr, double *t, unsigned int *tp, TJacobian *sJ, unsigned int nvs, boolean *systemVars, unsigned int *ms, double *pl, unsigned int *ns, double ***path, Tchart *c)
Defines the path to a point in the chart.
Definition: chart.c:1477
A polytope associated with chart on a manifold.
Definition: cpolytope.h:52
unsigned int n
Definition: chart.h:75
double ChartErrorFromParameters(double *t, double *p, unsigned int *tp, Tchart *c)
Identifies points inside the defined error.
Definition: chart.c:1229
unsigned int ClassifyPointInChart(Tparameters *pr, boolean error, TJacobian *sJ, double *p, unsigned int *tp, double *t, Tchart *c)
Identifies the position of a point w.r.t. a given chart.
Definition: chart.c:1629
TAtlasBase * GetChartWorld(Tchart *c)
Returns the world defining the manifold.
Definition: chart.c:928
double eCurv
Definition: chart.h:80
The Jacobian of a set of equations.
Definition: jacobian.h:23
double * GetChartTangentSpace(Tchart *c)
Gets the chart tangent space.
Definition: chart.c:970
double ChartVolume(Tparameters *pr, boolean collisionFree, unsigned int *tp, TJacobian *sJ, Tchart *c)
Estimate the volume of a chart.
Definition: chart.c:1406
void SaveChart(FILE *f, Tchart *c)
Stores the chart information on a file.
Definition: chart.c:1877
boolean FrontierChart(Tchart *c)
Identifies frontier charts.
Definition: chart.c:1282
boolean IntersectCharts(Tparameters *pr, unsigned int *tp, Tbox *ambient, unsigned int id1, Tchart *c1, unsigned int id2, Tchart *c2)
Intersects two local charts.
Definition: chart.c:1270
void IncreaseChartSamplingRadius(Tchart *c)
Increase the sampling radious of the chart.
Definition: chart.c:1379
void AddBorderConstraint(Tparameters *pr, double *t, unsigned int *tp, Tbox *ambient, Tchart *c)
Crops the domain for a given chart.
Definition: chart.c:229
boolean ExpandibleChart(Tchart *c)
Identifies boundary charts.
Definition: chart.c:1292
Definition of the Tparameters type and the associated functions.
boolean frontier
Definition: chart.h:85
boolean InsideChartPolytope(double *t, Tchart *c)
Checks if a parameter point is inside the chart polytope.
Definition: chart.c:1313
void GetChartNeighboursFromVertices(Tparameters *pr, unsigned int *nn, unsigned int **cID1, unsigned int **cID2, Tchart *c)
Returns the identifier of neighbouring charts coincident at a vertex.
Definition: chart.c:1704
void Local2Global(double *t, unsigned int *tp, double *p, Tchart *c)
Transforms a parameter in tangent space to a point in ambient space.
Definition: chart.c:1212
Tscpolytope * sp
Definition: chart.h:108
double GetChartRadius(Tchart *c)
Returns de range of the chart.
Definition: chart.c:938