Make a Triangle

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
maxs
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 421
Joined: Sat Jun 24, 2006 12:02 am
Contact:

Make a Triangle

Post by maxs » Sat Sep 27, 2008 10:15 pm

Is it possible to construct a triangle by passing it 3 angle measurements?

I tried combining 3 separate angles using "arcangle", but I can't get them to connect.

Any ideas? Thanks, Max

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Contact:

Post by malte » Sat Sep 27, 2008 10:49 pm

Hey max,

as an AE user you have it pretty easy here. You can use the pointOnCircle function to construct a triangle.

Code: Select all

on mouseUp pMouseBtnNo
    start using stack "animationengine"
    local tList
    put pointOnCircle(100,100,0,80) into tlist
    put cr & pointOnCircle(100,100,90,80) after tlist
    put cr & pointOnCircle(100,100,180,80) after tlist
    put cr & pointOnCircle(100,100,0,80) after tlist
    set the points of grc "freehandPoly" to tList
end mouseUp
HTH,

Malte

maxs
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 421
Joined: Sat Jun 24, 2006 12:02 am
Contact:

Triangle

Post by maxs » Sun Sep 28, 2008 12:16 am

Wow, thanks Malke,

I was almost 100% sure that this could not be done. You had a solution in minutes. Thanks. Animation Engine has been a lifesaver.

I am unable to test the code. For some strange reason, the script requires an AE password. My AE 2.0 password does not work. Any ideas? Max

maxs
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 421
Joined: Sat Jun 24, 2006 12:02 am
Contact:

Try- angle

Post by maxs » Sun Sep 28, 2008 8:59 am

Hi Malke,

The password problem seems to reside in Rev 3.0 only.

But the code was unclear as how to set the angles. I need to be able to set the angles of two corners of the triangle, so your code may not work. For example, if one corner is 60 degrees, another might be 90 degrees.

Thank you, and please let me know if you have any ideas. Max

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Contact:

Post by malte » Sun Sep 28, 2008 10:10 am

Hi Max,

first for the unlock code problem. Which version of AE are you using? I do not see the problem here in 3.0 with the latest AE version at least.

Could you please explain what exactly it is you are trying to do? Do you want to set the angle at each point of the triangle? If so the code might need to change. What my previous example does is take 3 points constructed around the center of the circumcircle of the triangle. If you want to calculate the point given the angle at each leg of the triangle, this is also possible, but requires a little more scripting.

All the best,

Malte

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Post by mwieder » Mon Sep 29, 2008 8:46 pm

Max- actually just three angles isn't enough information to generate a unique triangle, rather it defines a class of similar triangles. You'd need more information - the length of one side, for example, or the positions of two points.

maxs
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 421
Joined: Sat Jun 24, 2006 12:02 am
Contact:

Post by maxs » Sun Oct 12, 2008 7:46 am

Thanks to all!

I realize now that construction a triangle using angles has a few inherent problems which do not make it practical. For example, a triangle with 2 80 degree angles would be very narrow or very large.

Thanks for the quick responses.

Post Reply