Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

A problem of geometry, assistance needed

Status
Not open for further replies.

PeterCharles

Mechanical
Oct 31, 2002
423
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!!
 
Replies continue below

Recommended for you

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? :)
 
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. :)
 
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.
 
It's OK, download this ZIP file.


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.
 
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.
 
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.
 
"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.

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

Online tools for structural design
 
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.
 
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.
 
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.
 
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor