FRDB Archives

Freethought & Rationalism Archive

The archives are read only.


Go Back   FRDB Archives > Archives > IIDB ARCHIVE: 200X-2003, PD 2007 > IIDB Secular Community Forums (PRIOR TO JUN-2003)
Welcome, Peter Kirby.
You last visited: Yesterday at 05:55 AM

 
 
Thread Tools Search this Thread
Old 05-07-2003, 06:56 PM   #1
Banned
 
Join Date: Sep 2001
Location: a place where i can list whatever location i want
Posts: 4,871
Question Math riddle

Say you're given two equal sets of numbers: one representing the lengths of lines and the other representing angle measures in degrees. Besides of drawing the polygon out, how can you be sure that the shape is fully enclosed? That is, just from the side lengths and angle measures, is there any formula that can be used to determine if a fully enclosed polygon can be made form them?

(For anyone who can tell why I'm asking this: yes, it would take too much time to redo all my shape classes to take in x,y coordinates instead of arrays of side lengths and angle measures, even though coordinates would guarantee an enclosed polygon. TOTALLY THINKING AHEAD WHEN I DESIGNED THEM, YESSIR.)
GunnerJ is offline  
Old 05-07-2003, 10:05 PM   #2
Obsessed Contributor
 
Join Date: Sep 2000
Location: Not Mayaned
Posts: 96,752
Default

#1: Sum (180 - angle) for all angles. If the answer isn't 360 it won't work.

#2: For each segment get it's angle relative to zero.
For all segments:
x = sum(cos(angle)*length)
y = sum(sin(angle)*length)

If X <> 0 or Y <> 0 then it doesn't work.
Loren Pechtel is offline  
Old 05-07-2003, 11:42 PM   #3
Veteran Member
 
Join Date: Apr 2001
Location: Heaven
Posts: 6,980
Default

Quote:
Originally posted by Loren Pechtel
#1: Sum (180 - angle) for all angles. If the answer isn't 360 it won't work.
Except for triangles, pentagons, hexagons, septagons, etc.

It's (n-2)180 degrees, where n=the total number of faces.

For #2, you have to arrange them as vectors (yes, I know, boo, hiss), determine their x and y components, and then sum it.
Jesus Tap-Dancin' Christ is offline  
Old 05-07-2003, 11:54 PM   #4
Contributor
 
Join Date: Jul 2000
Location: Lebanon, OR, USA
Posts: 16,829
Default

IMO, the simplest way is to calculate x,y coordinates from the line lengths and angles.

CumAng = 0;
X = 0;
Y = 0;
for all side/angle sets:
CumAng += (180d - Angle);
X += Side*cos(CumAng);
Y += Side*sin(CumAng);
endfor

If the shape is closed, then the final position will be (X=0,Y=0) -- the initial one.

GunnerJ, it looks like you ought to redo your shapes classes with (x,y) coords; your side-angle approach leaves position and rotation undetermined, and it does not guarantee closure.
lpetrich is offline  
Old 05-08-2003, 04:07 AM   #5
Banned
 
Join Date: Oct 2000
Location: Bloomington, MN
Posts: 2,209
Default

Let X be the number of lines, and Y be the sum of the angle degrees. The polygon is enclosed if and only if X = (Y/180)+2.

I think.


Dave
Silent Dave is offline  
Old 05-08-2003, 09:01 AM   #6
Banned
 
Join Date: Sep 2001
Location: a place where i can list whatever location i want
Posts: 4,871
Default

lpetrich: You're right, a coordinate system would be the smart thing to do. But I'm really out of time. Maybe if I was thinking ahaead, I'd have realized that the best way to sonctruct these shape classes would be to have them take in an array of structs (containing x,y coordinates). But I didn't so I'm stuck.

Tap dancing: so, your formula is ((number of sides -2) * 180) - sum of angles, and if it doesn't equal 360, it's wrong?

Silent Dave: I'll check this out too.

Thanks all.
GunnerJ is offline  
Old 05-08-2003, 09:13 AM   #7
Veteran Member
 
Join Date: Apr 2001
Location: Heaven
Posts: 6,980
Default

Quote:
Originally posted by GunnerJ

Tap dancing: so, your formula is ((number of sides -2) * 180) - sum of angles, and if it doesn't equal 360, it's wrong?
No--that is what the total of the angles should be.

Add up all of the angles. Now apply (n-2)180. If those two numbers are different, then it will not be enclosed. A pentagon, for example, has 540 degrees, whereas a triangle has 180. Only circles and paralellograms have 360 degrees in them.
Jesus Tap-Dancin' Christ is offline  
Old 05-08-2003, 09:31 AM   #8
Veteran Member
 
Join Date: Apr 2001
Location: Heaven
Posts: 6,980
Default

Quote:
Originally posted by GunnerJ

Tap dancing: so, your formula is ((number of sides -2) * 180) - sum of angles, and if it doesn't equal 360, it's wrong?
No--that is what the total of the angles should be.

Add up all of the angles. Now apply (n-2)180. If those two numbers are different, then it will not be enclosed. A pentagon, for example, has 540 degrees, whereas a triangle has 180. Only circles and paralellograms have 360 degrees in them.
Jesus Tap-Dancin' Christ is offline  
Old 05-08-2003, 09:32 AM   #9
Banned
 
Join Date: Sep 2001
Location: a place where i can list whatever location i want
Posts: 4,871
Default

OK, but how does this account for varying side lengths? Or is there no way to do this outside of x,y coordinates?

I guess I'm kind of confused about what Loren means by "angle relative to zero." How does the second forumla work?
GunnerJ is offline  
Old 05-08-2003, 09:51 AM   #10
Veteran Member
 
Join Date: Apr 2001
Location: Heaven
Posts: 6,980
Default

You need x-y coordinates. Loren tells how to get there by way of his formula

What Loren means is the angle relative to a line that is drawn from nearby the object--either parallel with a base, or perpendicular to it (parallel is a much simpler option, by the way). By taking the cosine of the each angle and the side it coresponds to (do each side once, whichever angle should be fine), you arrive at the x component for that segment. The sine will give the y component. If you add the x components up, they should equal zero, and y components should simlarly combine to zero.

Try this with a square. You have l*sin 90+l*sin 270 for the y components (which gives sum zero), and l*cos 0+l*cos 180 for the X components (which also gives zero)..
Jesus Tap-Dancin' Christ is offline  
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump


All times are GMT -8. The time now is 09:35 PM.

Top

This custom BB emulates vBulletin® Version 3.8.2
Copyright ©2000 - 2015, Jelsoft Enterprises Ltd.