How do I access the original point in periodic 2 D Triangulation in CGAL? - cgal

I did the periodic triangulation of five points with the default domain.The points were (0.2,0.3), (0.5,0.1), (0.7,0.6), (0.8,0.8), (0.5,0.11). After iterating over the faces for 1 sheeted covering and printing the output, I got this result:
0.8 0.8 , 0.7 0.6 , 1.2 1.3 and so on.
I know the points 1.2 1.3 means the point 0.2 0.3 as the domain is iso_ rectangle. But I want it to print 0.2 0.3 instead of 1.2 1.3 so that I could find the delaunay neighbours of a given vertex.
Thank you

If you have a vertex v of the periodic triangulation t, then t.periodic_point(v) gives you a periodic point, whose first element is a point in the original domain. I guess that this point is what you are looking for.
See
http://doc.cgal.org/latest/Periodic_2_triangulation_2/classCGAL_1_1Periodic__2__triangulation__2.html#a217b56b0d5a8c222573f520a69a696ee
and
http://doc.cgal.org/latest/Periodic_2_triangulation_2/classCGAL_1_1Periodic__2__triangulation__2.html#abc48042ca1cff117f7c5201c0ffdabfa

Related

How to chart a line and a fixed point in the same chart in Looker

I want to compare precision-recall curve of my model to current rule based model precision-recall. So I want to have a chart with a line and a fixed point. Data looks like following:
threshold
precision
recall
current precision
current recall
0.01
0.05
0.93
. 0.55
. 0.35.
0.02
0.07
0.87
. 0.55
. 0.35.
0.03
0.09
0.81
. 0.55
. 0.35.
.
.
.
Please note current precision/current recall values are constant for each row.
I want to have a line (or scatter plot) of precision recall and mark the current precision/recall point in the same chart.
Is there a way to do this in Looker?
Go to the chart option under the "Series" tab (see pic 1), and for current precision/recall, change the type to scatter. For the remaining dimensions( precision and recall curve), change it to an area or line chart. Also, you can even go to the "Y" tab and drag current recall and precision to the right axis if you want. The final result should be similar to pic 2.

1D spherical grid in FiPy

I would like to solve the diffusion equation in FiPy in spherical coordinates on a 1D grid. I would also like the left boundary to be at r=0.1, not r=0.
I can't find a module for 1D spherical symmetry; only cylindrical. I figure I do it with Grid1D and simply write the del^2 operator in spherical coordinates, then multiply through by r^2 (as mentioned here). However, I still don't know how to specify the locations of the boundaries.
Could someone advise me how to do this? Many thanks.
All fipy meshes can be offset by a vector of appropriate dimension, e.g.,
>>> m = fp.Grid1D(nx=10, dx=.1) + [[1.5]]
>>> print m.x
[1.55 1.65 1.75 1.85 1.95 2.05 2.15 2.25 2.35 2.45]
A spherically symmetric mesh, mirrored on CylindricalUniformGrid1D, would be a welcome pull request.

Calculate radius and remove GPS coordinates

I have a question about how to remove some "unnecessary" coordinates from a "maps.txt" file using segment line, projection vector or other method.
Path Created on Google Maps:
Map1
Total of 275 coordinates, extracted from the ".KML" file of Google Maps.
Map1_2
Map2
When I do it manually it stays that way (Map2), with 9 coordinates.
I have a file called "maps.txt" where its lines, with coordinates, are in this format:
Obs: A coordinate on each line: latitude, longitude.
-37.2012600, -59.8404600
-37.2000200, -59.8419600
-37.1985300, -59.8439200
-37.1970600, -59.8458500
-37.1959100, -59.8473500
-37.1957800, -59.8475200
-37.1948600, -59.8486900
-37.1939500, -59.8498600
-37.1931400, -59.8509400
-37.1928400, -59.8513100
-37.1926700, -59.8515000
-37.1924600, -59.8517200
-37.1922600, -59.8519200
Is there any way for a code to read my file "maps.txt" and do the line segment, vector projection, point distance calculation using a radius of 100 meters?
In case the code would "remove the line / unnecessary coordinate" from the file "maps.txt", leaving it this way (just an example):
-37.2012600, -59.8404600
-37.1948600, -59.8486900
-37.1922600, -59.8519200
In Python, C, C ++ or another language.
I hope I have been clear and thank you in advance for any help.
Thank you (:
I'll try to explain better.
In the following figure I have 3 coordinates (1, 2 and 3).
The coordinate "1" has a radius within 100m with respect to the "2" coordinate, but from "1" to "3" I have a value greater than 100m, ie in this case the coordinate "1", "2" "and" 3 "in my text file" maps.txt ".
Example1
In the following figure from example 2, I would need only the coordinates "1" and "3" in the file "maps.txt".
Example2
Update:
Here's a script that converts KML to GPX: https://gist.github.com/timabell/8791116
And here's a Python script that seems like it'll do what you want (for GPX files): https://wiki.openstreetmap.org/wiki/User:Travelling_salesman/gpx_reduce
Previous answer:
I don't know how far you're asking us to take our answers; this problem is slightly complex, so here's some pseudocode for starters:
Overall algorithm:
Vector from point 1 to 3. Check distance of point 2 from this vector. (Assuming threshold is okay)
Vector from point 1 to 4. Check distance of points 2 and 3 from this vector. (Assuming threshold is okay)
Vector from point 1 to 5. Check distance of points 2, 3, and 4 from this vector. (Assuming threshold is bad)
First vector is determined: it's from point 1 to 4. Second vector starts at point 4.
Vector from point 4 to 6. Check distance of point 5 from this vector.
Vector from point 4 to 7. Check distance of points 5 and 6 from this vector.
...
Distance of point from vector:
At this point, we need to make a decision:
If we want this to be (quite) exact, we have to find a line that is perpendicular to our line and goes through this point, and find the intersection of these two lines. Then, we calculate the distance using the haversine formula between the intersection and the point. (Unless we sometimes have longer distances between coordinates, I don't think we need this.)
If we don't care too much about exactness, we use the following formula to calculate the "distance", and then "experimentally" find a good threshold value that works for us. (This threshold value is just some float number that we use when checking the distance. If it's above the threshold value, we start a new line.)
https://en.wikipedia.org/wiki/Distance_from_a_point_to_a_line#Line_defined_by_two_points
(Where (x0, y0) is the point we're investigating, and the line goes through (x1, y1) and (x2, y2).)

How to orchestrate members in a cluster to read new input from a single file once the current job is done?

I am working on a global optimization using brutal force. I am wondering if it is possible to complete the following task with Fortran MPI file I/O:
I have three nodes, A, B, C. I want these nodes to search for the optima over six sets of parameter inputs, which are arranged in the following matrix:
0.1 0.2 0.3
0.4 0.5 0.6
0.7 0.8 0.9
1.1 1.2 1.3
1.4 1.5 1.6
1.7 1.8 1.9
A row vector represents a set of parameter inputs. The order of which node reading in which set of parameter inputs does not matter. All I need is to orchestrate nodes A, B, C to run through the six sets of parameters, obtain the corresponding value of penalty function, and save the output to a single file.
For example, node A pulls the first set, node B the second, and node C the third. Each node takes a while to finish respective computation. Since the computation time varies across nodes, it is possible that C is the first that finishes the first-round computation, and followed by B and then A. In such a case, I want node C to subsequently pull the forth set of inputs, node B to pull the fifth and node A to read in the last set.
A <--- 0.1 0.2 0.3
B <--- 0.4 0.5 0.6
C <--- 0.7 0.8 0.9
C <--- 1.1 1.2 1.3
B <--- 1.4 1.5 1.6
A <--- 1.7 1.8 1.9
What troubles me is that the order of which node to read which set for the second-round computation is not known in advance due to the uncertainty in the run time of respective node. So I would like to know if there is a way to dynamically program my code with MPI file I/O to attain such a parallel need. Can anyone show me a code template to solve this problem?
Thank you very much.
Lee
As much as it pains me to suggest it, this might be the one good use of MPI "Shared file pointers". These work in fortran, too, but I'm going to get the syntax wrong.
Each process can read a row from the file with MPI_File_read_shared This independent I/O routine will update a global "shared file pointer" bit of state. Should B or C finish their work quickly, they can call MPI_File_read_shared again. If A is slow, whenver it calls MPI_File_read_shared it will read whatever has not been dealt with yet.
Some warnings:
shared file pointers don't get a lot of attention.
The global bit of shared state is typically... a hidden file. So yeah, it might not scale terribly well. Should be fine for a few tens of processes, though.
the global bit of shared state is stored on a file system. Some file systems like PVFS do not support the locking required to ensure this shared state is always correct.

Save face color in .obj file

I have an .obj file storing triangle mesh. I wish to record a color for each of the triangle faces. Is there a way to save this information into .obj file so that software like MeshLab could identify and visualize it?
It's way too late to help you but since I came across the same problem, someone might have the same problem later.
Here is how I would do it :
As you can read on Wikipedia's page about .obj file format,
Some applications support vertex colors, by putting red, green and blue values after x y and z (this precludes specifying w). The color values range from 0 to 1.
This method is now widely supported. I figured out that giving vertices the proper colors, will make most software (including MeshLab) automatically color the faces with those. This is advantageous when you want to store everything in an OBJ file.
v 0.0 0.0 0.0 1.0 0.0 0.0
v 0.0 0.5 0.5 1.0 0.0 0.0
v 0.5 0.5 0.0 1.0 0.0 0.0
f 3//3 2//2 1//1
Will make a red triangle.
Obviously, it will look way better if you use a MTL file. But this is quick to make and useful for testing your code when you do 3D scan. Also I did not try this with indexed vertices, so it might not work the same way.