A problem of geometry, assistance needed
A problem of geometry, assistance needed
(OP)
I could do with some assistance here!
I have three points that I know the coordinates of, "C" the centre of an arc, "S" the start point of the arc, "E" the end point of the arc.
Clearly, the arc will be either clockwise or anti-clockwise about "C".
If I draw out the three points I can immediately see the rotation, but I'm looking for a geometric/mathematical method to determine the rotation. I need to incorporate this into a program I'm writing.
Currently I'm a bit stuck!!
I have three points that I know the coordinates of, "C" the centre of an arc, "S" the start point of the arc, "E" the end point of the arc.
Clearly, the arc will be either clockwise or anti-clockwise about "C".
If I draw out the three points I can immediately see the rotation, but I'm looking for a geometric/mathematical method to determine the rotation. I need to incorporate this into a program I'm writing.
Currently I'm a bit stuck!!





RE: A problem of geometry, assistance needed
CODE
IF AngleECX=AngleSCX THEN GOTO .....
Whilst doing this by looking at angles there is an opportunity to check that each point is exactly equidistant from C.
RE: A problem of geometry, assistance needed
1) let the start angle SCX be 350 degrees
2) let the end angle ECX be 10 degrees
then since SCX > ECX the rotation would be would be given as NEG, whereas its actually POS, that's why I'm stuck.
RE: A problem of geometry, assistance needed
Unless you make a rule such as "it will always travel the shortest distance", you can't know...
RE: A problem of geometry, assistance needed
If SCX=190 and ECX=10 then there are two equal and opposite, ways to rotate. So, if the critical angle is ECX+180, then we can find which route is shorter.
But if ECX is more than 180 then the critical angle will be ECX-180.
CODE
ELSE CriticalAngle=ECX+180
IF SCX>CriticalAngle AND SCX<ECX THEN R=POS
IF SCX>CriticalAngle AND SCX>ECX THEN R=NEG
IF SCX<CriticalAngle THEN R=NEG
RE: A problem of geometry, assistance needed
The arc is part of the loop path traced out by a laser cutter which consists of lines and arcs. I know the overall rotation of the path be it clockwise or anti-clockwise. The lines are straight with a start point and end point, so no problem.
However within the context of the loop the arcs may be clockwise or anti-clockwise about their respective arc centres depending on the position of the arc centre relative to the loop. If the centre is "inside" the loop then the rotation is the same loop, but if it is "outside" then the rotation is opposite to the loop. (Does this make sense?)
RE: A problem of geometry, assistance needed
RE: A problem of geometry, assistance needed
Hence the request for assistance
RE: A problem of geometry, assistance needed
visualise a path from a vertical line to a horizontal line heading to the right. the direction of the cutter (from up to the right) has rotated CW, so the arc would also be CW, center to the right of the original line.
btw, isn't an angle of 180deg meaningless (in this context)?
also, one point to consider is a sharp corner (ie corner radius = cutter radius)
RE: A problem of geometry, assistance needed
the information you provided is not yet sufficient to decide.
You can easily connect two lines with an arc whose center will lie inside the loop if you go one way and outside if you go the other way.
Is there any other restraint for your arcs you didn't mention? Are for example the tangents to the arc in the endpoints coincident with the line segment connected to each endpoint?
Also: when you say that the center is internal to the loop, is this the same as saying that it will be internal to the loop obtained by joining all the points with lines? A simple mathematical check can determine the internity of a point to a poligonal closed loop (with no crossing lines of course).
prex
http://www.xcalcs.com
Online tools for structural design
RE: A problem of geometry, assistance needed
The laser is quite happy with square corners.
I was wondering if checking how the slope of the arc varied in the direction of travel might give a clue .....
RE: A problem of geometry, assistance needed
RE: A problem of geometry, assistance needed
RE: A problem of geometry, assistance needed
maybe the inherent logic is to choose the shorter path ? (so if you wanted a 270deg cut you'd define this as two 135 deg cuts)
RE: A problem of geometry, assistance needed
Do you know the desired shape of the output path? If so, can you generate your path by arbitrarily selecting either a CW or CCW direction for your arcs and then finalize the path manually by correcting the arcs that are wrong? I have no idea how many files you need to do, but it seems that you'll need to verify the path in some fashion after the DXF is generated anyway. I would imagine that any arcs that get generated in the wrong direction would be painfully obvious, but that's total supposition on my part.
Or are you trying to generate a path that you know nothing about other than what's being given in the text file? If this is the case, I wish you the best of luck.
RE: A problem of geometry, assistance needed
"A simple mathematical check can determine the internity of a point to a poligonal closed loop" Could you give me a clue please.
dgowans,
No question is stupid.
1)The data in the text file tells me if the loop is clockwise or anti-clockwise.
2)I can always check the DXF after creating it as the error will be obvious. But ideally I'd like to get the conversion right.
3)The directory contains 40,000 files of which maybe 25-30,000 are laser profiles. Whether we need them all again is another matter, but there are attractions if we could do a "one hit" with a program.
"Smile and be happy, things could be worse.
So I smiled and was happy and sure enough things got worse!"
RE: A problem of geometry, assistance needed
if the data file tells you the start, stop, and center positions, and whether the arc is CW or CCW ...
what else is there to figure out ??
if you're looking to check your conversion, could you use your translated file to generate the equivalant input file and compare the two files ?
RE: A problem of geometry, assistance needed
How Do I Make Files Available For Download? ... No Emails Required FAQ559-1177
RE: A problem of geometry, assistance needed
I almost posted the exact same thing until I noticed that he said he knew the direction of the loop (i.e. the overall travel direction wrt the shape's center), not each arc(wrt its center).
RE: A problem of geometry, assistance needed
RE: A problem of geometry, assistance needed
RE: A problem of geometry, assistance needed
I'll look at sorting out some files, it may be there is more useful data that I haven't recognised. It's a pain you can't attach files in this forum.
Oh, I did wonder about adding it to the "Puzzles/Games, Interesting Questions" thread.
RE: A problem of geometry, assistance needed
RE: A problem of geometry, assistance needed
http://www.dolphin-ds.com/dl_files/sample.zip
This may give you a start it's the bets I've with me at the moment, but it hasn't got any "internal" loops, only circles, and "internal" loops seem to rotate in the opposite direction to "external" loops. And imagine if the component was positioned differently, particularly if an arc crossed the zero angle line.
RE: A problem of geometry, assistance needed
More mathematically, compare the gradients (dy/dx) for the line and the arc.
Cheers
Greg Locock
Please see FAQ731-376 for tips on how to make the best use of Eng-Tips.
RE: A problem of geometry, assistance needed
Each type of entity with length has a few integer numbers associated with it. These integers refer to the P entries at the beginning of the file, which are XYZ coords of points.
I notice that the part you've given has four arcs in the outline. Three are concave and one is convex from the perspective of inside the loop. The one convex curve is the one between two other curves, so obviously these three adjacent curves are represented by:
CODE
1 0
3 2 4
1
|~
ARC
1 0
7 4 9
-1
|~
ARC
1 0
10 9 11
1
|~
I have no idea what the significance of the "1 0" pair is, because it is the same for every entity. The next triple are the numbers for the "P" point entries for arc center, start, and end points.
Could your solution be as simple as looking at that next number below the triples? The LINE entities don't have that number, and it is negative for the one arc that is convex. I can't confirm that because I only have one file, but I can't see any other purpose for that number, nor can I see any other bit of data somewhere else that could designate the arc direction.
RE: A problem of geometry, assistance needed
But there's no reason why the gradients of the line and arc must be the same at the intersection point (line tangent to arc). They might be, but it just depends on the shape you're cutting.
RE: A problem of geometry, assistance needed
Cheers
Greg Locock
Please see FAQ731-376 for tips on how to make the best use of Eng-Tips.
RE: A problem of geometry, assistance needed
b = (xs-xc)(ye-yc) - (xe-xc)(ys-yc).
if b = 0, then b = 1; otherwise b = b/abs(b).
if b = -1, rotation is clockwise;
if b = 1, rotation is anticlockwise.
RE: A problem of geometry, assistance needed
What I have deduced :
at the start of the file there are groups of three lines
P - a point
n - the point number
x, y, z - the coordinates of the point
there are groups of lines and arcs forming a loop preceeded by #~33, then
n, 24, 0 or 1
n - the loop number
24 - ??
0 anti-clockwise, 1 clockwise
lines are
LIN
1 - layer number
0 - ??
start point, end point
arcs are
ARC
1 - layer number
0 - ??
arc centre, start point, end point
1 or -1
This last line I hadn't recognised, but I think you are right, 1 is anti-clockwise, -1 is clockwise !!
I need to check it out with some more files. Thank you for pointing this out.
RE: A problem of geometry, assistance needed
Note also that, because of rounding off, the entities in the .dxf have non coincident endpoints: if you plan to use it only for visualization it's OK, but if you want to further elaborate, you should consider generating polylines for each contour, instead of separate entities.
Concerning the internity test, I suppose you don't need it anymore. Otherwise tell me, I must retrieve it from my documentation.
prex
http://www.xcalcs.com
Online tools for structural design
RE: A problem of geometry, assistance needed
Yes, I probably don't need the internity test. However, having done so much I'd be interested in seeing it when you've got a few spare minutes.
RE: A problem of geometry, assistance needed
a = global loop rotation (-1 for clockwise, 1 for anticlockwise).
b = (xs-xc)(ye-yc) - (xe-xc)(ys-yc).
if b = 0, then b = a; otherwise b = b/abs(b).
if b = -1, arc rotation is clockwise;
if b = 1, arc rotation is anticlockwise.
if b = a, arc centre point has internity.
RE: A problem of geometry, assistance needed
1) Make a linear translation of coordinates so pt C goes to 0,0.
2) Then rotate the system about 0,0 using the standard sine/cosine matrix, unil point S' the rotated starting pt is on the x axis. Now get the Y coordinate of pt F', the final rotated point. If it is positive, then system is CCW; negative, CW.
This only assumes the ars you are doing is the smaller of two possible arcs.
RE: A problem of geometry, assistance needed
May I thank all those who responded to my request for assistance. The level of response exceeded my expectations and shows that there are "good guys" out there willing to give assistance to those who ask.
Once again, thank you.