I am currently working on a project that involves measuring distances all around a robot with a laser module, the robot then has to move based on the points that he gets.
I currently have access to 360 points that represent the distance from the center for each of the corresponding angles. (a distance for 0°, a distance for 1°, etc)
Here's an example of what the points look like when displayed on a 2D surface:
Circular representation of the points
What I'd like to be able to do is, rather than feeding the robot all 360 points, to feed it segments containing multiple points. For instance, the bottom part of the image would be a single segment even though the points are not completely aligned.
My question to you is, is there an existing algorithm that would help me achieve what I am trying to do?
(I'm working in python but that shouldn't really be a factor)
Thanks a lot.
Assuming your points are ordered:
For each point, look ahead by two points, if the middle point is less than some distance away from the segment between the two points, then push your endpoint 1 pt further, and check that now both of the middle points are still within some distance of your line segment. Proceed to do this until false, at which point roll back one pt and generate a segment, then set the end of that segment as the start of your next segment. Also, you could consider angles instead of just distances as there are some cases where that would be favorable. Also, if no segment can be made from a certain start point for several attempts, push the start point forward one (as not everything is going to simplify into segments)
Alternately, you could convert to Cartesian points and use the hough voting algorithm to detect lines from the resulting point-cloud.
Can i easily calculate this programmatically?
I can calculate it easily when the two hexahedrons are convex,
but them can be concave.
Is there just an only way to calculate intersections of the line segments and half planes?
Because you write about "intersections of line segments", I assume that you are asking about hexagons, not hexahedrons:
You should use the same method as for general polygons, so basically check for segment intersections. The naive implementation is O(n*n) but in your case with fixed n=6 this might not even be an issue.
You probably also want to check if one of the hexagons is completely inside the other one. If you already found out that there is no intersection, you just have to check if one point of the polygon is inside the other one. Again, you should use the method for general polygons.
I have a bit of a theoretical questions.
Lets say i have 2 paths in svg. Each with a different number of points. One has 4 Bézier curves and the other 3.
What i want to do is morph one into the other.
Now, i know they have to have the same exact structure and same number of points to do so.
So, the question is, can i add "virtual points" into their paths to get the same structure and number of points, without changing the shape of the objects?
For example, taking one point in one of the paths and just adding the same point after it to increase the number of points. Or creating a Bézier curve in both paths that would actually pretend to be a line instead of a curve. Would that change the object? And if i have points on x=1 y=1 and x=4 y=4, would using this form make Bézier curve a line? (M1 1C1 1 4 4 4 4)
Figured it out. Using control points anywhere on the same line as the coordiantes transforms the Bézier into a line, also if you use the same point as both the control points, start and end coordinate you can make the curve into a point. Adding more of these points into path doesnt change the look of the object, just adds more data into the path.
http://www.petercollingridge.co.uk/book/export/html/560
Down at the cubic curves you can align the points in the described manner to get the desired result
I have a simple to use d3 plugin to animate svg path which supports different number of points, also it animates only the parts of the path which differs from original path, not the whole path.
7kb minified: https://pratyushcrd.github.io/d3-path-morphing/
I am currently wondering if there is a common algorithm to check whether a set of plane polygones, not nescessarily triangles, contruct a watertight polyhedra. Each polygon has an oriantation (normal vector). A simple solution would just be to say yes or no. A more advanced version would be to point out the edges, where the polyhedron is "open". I am not really interesed on how to close to polyhedra.
I would like to point out, that my "holes" are not nescessarily small, e.g., one face of a cube might be missing. Thus, the "undersampling correction" algorithms dont seem to be the correct approach. Furthermore, I am talking of about 100 - 1000, not 1000000 polygons, so computation time should not really be a problem.
Any hints or tips?
kind regards,
curator
I believe you can use a simple topological test -- count the number of times each edge appears in the full list of polygons.
If the set of polygons define the surface of a closed volume, each edge should have count>=2, indicating that each edge is shared by (at least) two adjacent polygons. If the surface is manifold count==2 exactly.
Edges with count==1 indicate open regions of the surface.
The above answer does not cover many cases. A more correct (but not necessarily complete: I wouldn't know) algorithm is to ensure that every edge of every polygon (or of the mesh/polyhedron) has an even number of faces connected to it. Consider the following mesh:
The segment (line) between the closest vertex and the one below is attached to 3 faces (one one of the outer triangle and two of the inner triangle), which is greater than two faces. However this is clearly not closed.
2D problem: I measure the position of the 3 ends of a triangle in a cartesian system. Now i move the system (triangle) to another cartesian system and measure the position of just two ends.
How can I identify the location of the 3rd end based on this data?
thanks! (and sorry for the bad english as a second angle)
This question is from 8 years ago, but even though it is a little vague, I think it could be answered fairly concisely, and if I have come across it then maybe someone else will come across it and gain some benefit from an actual real answer rather than the one which was accepted. (I apologize for accidentally upvoting the accepted "answer". I had originally downvoted it, but realized that the question was actually a bit vague and tried to reverse my downvote. Sadly, because of my noob rep, that seems to have translated into an actual upvote. It didn't deserve the downvote, but it didn't deserve an upvote, either.)
Lead-Up
So, lets say you have a simple cartesian grid, or reference frame:
And within that 10x10 reference frame you have a triangle object:
I failed to lable the images, but the (a, b, c) co-ordinates of this triangle are obviously a=(0,0), b=(0,4), and c=(4,0).
Now let's say that we move that triangle within our cartesian reference frame (grid):
We've moved the triangle x=x+1 and y=y+1, therefore, given that the new co-ordinates of "b" and "c" are b=(1,5) and c=(5,1), what is "a"?
It's pretty obvious that "a" would be (1,1), but looking at the math we can see that
Δb=b2-b1
Δb=(x2,y2)-(x1,y1)
Δb=(1,5)-(0,4)
Δb=(1-0, 5-4)
∴Δb=(1,1) or (+1,+1)
If we do the same for the two "c" co-ordinates we arrive at the same answer, Δc also equals (1,1), therefore it's a translation (a linear movement) and not a rotation, which means that Δa is also (1,1)! So:
a2=a1+Δa
a2=(0,0)+(+1,+1)
a2=(0+1,0+1)∴
∴a2=(1,1)
And if you take a look at the image you can clearly see that the new position of "a" is at (1,1).
Translation
But that's just the lead-up. Your question was in converting from one cartesian reference frame to another. Consider that your 10x10 reference frame is within a larger reference frame:
We can call your 10x10 grid a "local" reference frame, and it exists within maybe a "global" reference frame. There may actually be a number of other "local" reference frames within this global reference frame:
But to keep it simple, of course we're going to just consider one cartesian reference frame within another:
Now we need to translate that "local" reference frame within the "global" reference frame:
So, "locally", the (a,b,c) co-ordinates of our triangle are still {(0,0),(0,4),(4,0)}, but the origin of our local reference frame is not aligned with the origin of the global reference frame! Our local reference frame has shifted (+3.5,+1.5)!
Now what's the position of our triangle?!
You basically approach it the same way. The relative position of our "local" reference frame is (+3.5,+1.5), which we will call Δf for difference in frames, therefore the triangle relative to the global origin will be ag=al+Δf, bg=bl+Δf, and cg=cl+Δf, where (ag,bg,cg) are the co-ordinates within the global reference frame and (al,bl,cl) are co-ordinates within the local reference frame.
Three-Dimensional Cartesian System
It's exactly the same, you just include the third "z" co-ordinate to the position of the triangle.
Rotation
One of the assumptions I'm making from your original question is that you were actually asking about translation and were not interested in rotation at the time that you asked this question 8 years ago.
Very quickly, however, you need to use trig in order to rotate your 2d object within your reference frame, so you need to first determine from where you're rotating your object, which we call a rotational axis. Then, once you decide where the rotational axis is, recalculate the (x,y) for each of the three points in your triangle:
x = r · cos θ
y = r · sin θ
where θ is the angle at which we're rotating the object, "r" is the distance of that point from the axis of rotation, and "·" just means multiplication.
So, if we were to rotate our triangle 30° counter clockwise around piont "a" it may look similar to this:
But, again, that wasn't your question. Your questions was, "given the locations of two of the points, determine the position of the third".
Without any explanation whatsoever, only because I don't think you were asking about rotation, what you do is you work backwards:
if x = r · cos θ, then θ = arccos(x/r)
Now you have the angle of rotation which you can now apply to the original position of the missing point to find its (x,y) and, as with our original translational example, also works from one cartesian reference frame to another. Meaning, that if your "local" reference frame rotates within the global reference frame, even though it appears that nothing has changed within your local frame, you can plot the locations of the points of your objects within the global frame.
And, again, that also works for 3D reference frames, as well.
And finally, if your cartesian local reference frame is both translated and rotated, which it almost certainly is, then you would apply both methods to plot your points onto the other (global?) cartesian reference frame.
Real-World Application
Oh, so many! Our brains do this so intuitively every day when we're driving or walking down the street that I don't know where to begin!
Translation is easy, but rotation gets a little hairy when crossing axes. One trick to make things easier is to translate the object from one frame of reference to another in order to make the trig more straight-forward.
Telling the story in pictures:
And that's just the start...
I hope that helps.
This is a pretty vague question, but if I'm reading it right, then you need even less information than that. If you have the transformation of the first coordinate system to the second, then apply that to each of the three points to find each of the 3 equivalent points.
Otherwise, if you don't have the transformation, I would think it's impossible. After all, an infinite number of possible transformations of a coordinate system can result in the same two locations of two points yet different locations of the third.