×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

A problem of geometry, assistance needed

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!!

RE: A problem of geometry, assistance needed

There are several ways of determining the direction of rotation, but in this case it may be easier to calculate the two angles involved; the angles of CE and CS to the horizontal, call them ECX and SCX. Then it's a simple IF/THEN operation to find the greater of the two.

CODE

    IF AngleECX>AngleSCX THEN R=POS ELSE R=NEG
    IF AngleECX=AngleSCX THEN GOTO .....
This is assuming that an Anti-clockwise rotation is Positive.

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

(OP)
Ah but ....

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.


sad(


RE: A problem of geometry, assistance needed

You can't tell which direction something moves over a closed circuit just by knowing its start and end points.  Think about it - if you know where a car starts and ends on a racetrack, but you're not allowed to see it move, there is no way of knowing if it went clockwise or counterclockwise.

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

A good point.

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

IF ECX > 180 THEN CriticalAngle=ECX-180
             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

(OP)
I'll expand on the problem a bit.

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

Your last paragraph clears it up completely.  You're right, this is a very easy thing to see when you draw the loop.  This requires you to visualize the entire loop.  However, for a computer program to calculate whether the center point is inside or outside the loop is going to be impossible without considering the geometry of the entire loop - a formidable undertaking indeed!

RE: A problem of geometry, assistance needed

(OP)
"... a formidable undertaking indeed!"

Hence the request for assistance   smile

RE: A problem of geometry, assistance needed

when you draw the cutter path it obvious, 'cause you've got the "big picture" and a little common sense.

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

PeterCharles
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

(OP)
"also, one point to consider is a sharp corner (ie corner radius = cutter radius)"
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

What are you using as input, something like a .dxf file?

RE: A problem of geometry, assistance needed

(OP)
The input file is the file (plain text) produced by the laser programming software (which we no longer have access to).  I'm attempting to reverse engineer this to produce a DXF file.  It's just the arcs that are a problem.

RE: A problem of geometry, assistance needed

maybe a NC programming company could help ?

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

This may be a stupid question, but I'll ask it anyway:

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

(OP)
prex,
"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

What else is in the text file?  It sounds like you've figured out how to get the center, start, and end points of each arc.  If the laser is supposed to run with just what's in the text file then there has to be something in there that tells the laser which direction to go.  Would it be an information security problem to post a couple of text files with their corresponding DXFs for reference?

How Do I Make Files Available For Download? ... No Emails Required  FAQ559-1177

RE: A problem of geometry, assistance needed

rb1957:
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

fair enough, but then there has to be something to tell the machine what to do ... conceptually either arc will satisfy the geometry (as described), but the macine doesn't guess which one's right ... and it does it right every time (well nearly)

RE: A problem of geometry, assistance needed

That's why I suggested posting some of the text files and DXFs - get a few more eyes looking at that file to see how it tells the machine which way the arc goes.  Perhaps posted to the "Puzzles/Games, Interesting Questions" thread?  smile

RE: A problem of geometry, assistance needed

(OP)
handleman,
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.  smile

RE: A problem of geometry, assistance needed

It's easy to make files available for download from one of the sites listed in FAQ559-1177 <-(click that link).  Just zip 'em, a couple of clicks, and you can post the link to them here.

RE: A problem of geometry, assistance needed

(OP)
It's OK, download this ZIP file.

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

Work out the velocity in x and y along the preceeding straight line. Do the same for the arc at the intersection. If they agree, you have guessed the direction of rotation correctly. If they are opposite, then you need to reverse the assumed direction of rotation.

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

OK, I'm guessing you've already figured this much out, so tell me if this is right:

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

ARC
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

(OP)
"compare the gradients (dy/dx) for the line and the arc"

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

if reentrant cuts are allowed then you'll have to specify a third point on the arc. I see no way around this.

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

PeterCharles:  Assuming your geometry is 2-D, would this work?

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

(OP)
handleman,

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

It could be that the 1 or -1 for arcs means 1=in the same direction as the entire contour and -1 the opposite: you should test with some more examples. Anyway I agree that those 1 and -1 indicate the direction of travel, as this piece of information is necessary, can't be recovered elsewhere (as also noted by others).

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

(OP)
prex,

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

PeterCharles:  The following assumes your geometry is 2-D, where c, s, and e subscripts mean arc centre point, start point, and end point, respectively. It uses the internity criterion defined in the last sentence of your third post.

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

Here's how I propose.
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

(OP)
I have now completed my file conversion utility program.

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources