5 Replies Latest reply on Mar 30, 2011 8:32 AM by Mylenium

# Closing an irregular polygon

Hi, I was wondering if After Effects (or any program really) can close an irregular polygon of four sides given only the lengths of the sides.  I am aware there may be several solutions but it may help to know I can take them all or perhaps the one with the largest area.  This is not actually for a video but rather I do not have any experience programming aside from expression scripts and I am in the process of setting up a random number generator that will basically take a sample of a very large set of possible answers to four linear equations that have the same independant variables.  The answers to these equations are generated by the random sample and I would like to express the answers as the length of a line segment that is a part of an irregular four sided polygon.  I have my reasons, but I need to be able to express the polygon so I can calculate the area of it, and so far my searches have not come across a method of closing a polygon without some angles.

The values that would represent the lengths of the lines are going to be stored on a null using a value controller as A, B, C, and D respectively.  I need to align four lines but I am unsure exactly what way I should go about generating the lines, ie which tool would be best to accomplish this.  I can send a project file by either tomorrow or Thursday that may shed some light on this if I am too confusing.  Really all I need is to close the polygon so I can start taking trig measurements and calculate the area.

Darren

• ###### 1. Re: Closing an irregular polygon
and so far my searches have not come across a method of closing a polygon without some angles.

Exactly! That "closing" part is not the issue, but how do you hope to determine a correct surface area? Different polygons with identical side lengths can have different surface areas depending on how they are shaped - basic 4th grade planar geometry. This is never gonna work, so you are looking for something that doesn't exist. Unless you have at least 2 known angles or 1 angle and the diagonal to constrain the shape, all your calculations will be ambiguous and the surface area will be meaningless.

Mylenium

1 person found this helpful
• ###### 2. Re: Closing an irregular polygon

Why would a mathematician even consider  a graphics package like After Effects for this task? Surely there are science or math or CAD applications that offer far more focused tools for this exercise. I know I can write research papers using Xcel but it's a lot more fun in Word.

bogiesan

• ###### 3. Re: Closing an irregular polygon

I figured as much.  Well is it possible to get all of the cases either way?  I am also aware this is not really the right program for this sort of work but like I said I have no access to or knowledge of any other possible program.  In all honesty I'm not even sure if this is the right way to go about the problem I have proposed in the first place.  However if this is the right method the polygons may produce several different cases but I am pretty sure the one with the best surface area should be one who's interior angles are all closest to 90 degrees.  Producing every possible case and tossing out unlikelies is definitely not something I would want to attempt in After Effects either.  What I do want is the polygon that produces the largest possible surface area, but it seems like a different route such as a kind of residual measurement is going to be best.  What I am attempting to do is optimize four linear equations at the same time, optimization being the highest possible values while also being very close together.  Constraints on the variables are currently limited and I figured its pretty similar to the maximization of a 4 sided polygon's surface area; seeing as a square has equal sides the maximized polygon would have to be very close to or be a square.

Does this help?  Probably not.  Thank you Mylenium.

Darren

• ###### 4. Re: Closing an irregular polygon

If you have the chops to program the expressions in After Effects ad cascade the results into additional situational filtering you have the chops to approach any Java-based math application.

Stop by Rick Gerard's expression shop and visit the AE  Enhancers site to ask these questions.

bogiesan

• ###### 5. Re: Closing an irregular polygon

pretty sure the one with the best surface area should be one who's interior angles are all closest to 90 degrees.

Nope! Example: If 2 angles are 90 degrees and the two sides near one corner are equal, but the other side is longer, as a result the effective shape would be a square with an additional triangle at the top and the surface area be larger than the square alone. You could calculate it in this example, because you knew the angles and the length of 3 sides, but not in other cases. However, this example also contains the answer: The largest possible surface area of the polygon is defined by the largest possible surface area of its sub-elements, i.e. triangles. Still, without any constraints you can only find the optimum one by sheer luck or using a statistical method where you simply try out all possible combinations of angles and only retain the largest one after a series of iterations. That in itself is nothing you would do in AE for performance reasons, but it would probably be doable as a Flash applet or Java applet in a browser.

Mylenium