I have two CSV files, each file contains list of 3D points include X, Y, and Z that represents a point in 3D space. The number of points in each file is not equal.
I write a program that reads points from CSV files and renders by OpenGL.
How can I measure the "distance / thickness (the space)" between two curved surfaces?
Are there any concepts / formulas about distance between two curved surfaces in 3D space?
Any keywords, theory, examples, illustrations, etc will help me very much.
Thanks and best regards,
Related
As the pic show, both curves are of spline line, and have limited points. I want to figure out the count of green points. Is there any idea?
I assume the black curve is x-monotone (otherwise the "one above the other" term can be ambiguous).
A simple approach is to consider the black curve as a polygonal line and for each point p on the red curve find the point q on the polygonal line with the same x-coordinate. Then the green points are those p that have a larger y-coordinate than their corresponding q.
Finding the point q corresponding to a given p amounts to going over the segments of the polygonal line and identifying segments that have one endpoint with smaller x-coordinate and the other with larger. Once you have such a segment the y-value of q is just a linear interpolation.
Since the polygonal line is x-monotone, the x-coordinates of the points are sorted. Therefore, the search for the corresponding segments can be done efficiently using logarithmic binary-search.
I would like to figure out a way to divide a map into polygons based on the half way positions of lat/long positions.
For example, if there are four lat/long positions on a map (titled "unknown Placemarkers" in the image), I'd like to create four polygons which represent the half way points between the four lat/long positiongs (shown as a yellow line in the image)
Similarly if there were three lat/long positions then the polygons would adjust to have areas which are split by the half way point between the three points.
And the final scenario is that if a lat/lng is surrounded by other polygons the polygon split would be fully enclosed according to the last image.
I am having a Three OBJ file, Cone, Sphere and Cube. How can I find the dimension of these objects, so that I can use it in my collision detection class?
i.e How can I find Radius, Length of Cube and Radius and Height of cone? Or is there any better way for collision detection, I have hundreds of random particle in my game which may or may not collide with these objects.
Length of the cube would be the distance of two consecutive points in one face.
If by radius of a cube you mean its diagonal it would be sqrt{3} of its length.
For a sphere, you can find its center by averaging all the vertices.
Its radius would be the distance between any vertex and the center.
It works fine if the sphere is not high resolution.
Otherwise, you have to solve a system of equations to find the sphere that passes through four points. You can take a look at this:
https://www.quora.com/How-do-you-find-the-center-and-radius-of-a-sphere-given-any-four-arbitrary-points-x_1-y_1-z_1-x_2-y_2-z_2-x_3-y_3-z_3-x_4-y_4-z_4
For the cone: there is probably one vertex that is connected to all other vertices. This vertex is probably easy to find for you. Let's call that p.
Take three vertex other than p. Find the circle passing through those vertices. Call that c. The distance between p and c is the height. The distance between c and any vertex other than p would be the radius. To find the circle passing through three points, you again need to solve a system of equations with three unknowns. As the equation of a circle is (x-a)^2+(y-b)^2=r^2. You need to put the values of your three points in the equation and find a,b, and r. Note that this equation assumes that the circle is in 2D. To use it for 3D, you need to first find the plane passing through these three points. If you do not want to go through all these. you can again average all vertices except p and find the center of the circle. the radius would be the distance between the center and any point. I actually assumed that the circles and spheres in your input are uniformly sampled which is the case for most of the available Obj files for these shapes.
I would like to calculate an arbitrarily oriented minimum (area) bounding box of a polygon on a sphere (as a simplification of Earth).
For an axis-aligned version I found the great example from Jason Davies.
The idea is to have as input a list of lon/lat coordinates for the points of the polygon and as output the coordinates of the 4 points (lon/lat) of the bounding box.
Bonus: consider the (very likely) cases where the polygon crosses the antimeridian, contains one pole and/or spans more than one hemisphere.
Does anyone know how to draw a circular, minor arc given the centre point and two other points that lie on the circle?
I want to draw the pixels directly to the screen, and preferably, not have to calculate the angles.
I am using SDL and C, but may be OK studying code given that uses a different language.
Thanks.
All points on a circle are equal distance to the centre.
Given you know two points on the circle you can calculate this distance.
Assuming you have cartesian coordinates, for every x or y value between the known points calculate the other value so that the point is equal distance to the centre and plot these points.
I think this is conceptually the easiest way, though not the most efficient.