Re: [Flashcoders] How to solve SSS triangle?

2005-11-22 Thread Rahul
Hi Ryanm,

Here is a function which I wrote a long time back. It calculates included
angle it uses cosine rule to calculate the angle.
The other function calculates shortest distance between two points.


function getAngle(vertex1,vertex2,vertex3){
 var a = (measureLength(vertex2,vertex3));
 var b = (measureLength(vertex3,vertex1));
 var c = (measureLength(vertex1,vertex2));
 var abc1 =  (((a*a)+(c*c)-(b*b)) / (2*a*c));
 var angle =(Math.round(Math.acos(abc1)*(180/Math.PI)));
 return(angle);
}

 function measureLength (obj1, obj2) {
var diffx = (obj2._x-obj1._x);
var diffy = (obj2._y-obj1._y);
  return (Math.sqrt((diffx*diffx)+(diffy*diffy)));
 }

Regards,
Rahul

- Original Message -
From: "ryanm" <[EMAIL PROTECTED]>
To: "Flashcoders mailing list" 
Sent: Tuesday, November 22, 2005 4:30 PM
Subject: Re: [Flashcoders] How to solve SSS triangle?


> >I am having 3 movie Clips named point1_mc, point2_mc, point3_mc in the
> > stage. They are arranged  in such a way to form a triangle...
> > Now how can i get those 3 angles and sides formed by these points.?
> >
> With a high school geometry textbook? ;-)
>
> Law of cosines: c^2 = a^2 + b^2 - 2ab*Cos(q)
> Where a, b, and c are the sides, and q is the angle opposite c
>
> ryanm
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] How to solve SSS triangle?

2005-11-22 Thread Pandian

Thank u... :-P

ryanm wrote:

I am having 3 movie Clips named point1_mc, point2_mc, point3_mc in 
the stage. They are arranged  in such a way to form a triangle...

Now how can i get those 3 angles and sides formed by these points.?


   With a high school geometry textbook? ;-)

Law of cosines: c^2 = a^2 + b^2 - 2ab*Cos(q)
Where a, b, and c are the sides, and q is the angle opposite c

ryanm
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders



--

Hi

Thanks and Regards,
Peria Pandi. J
Flash Programmer,
+91 9886742392
Excel-Soft Technologies Pvt Ltd,
1-B,Hotagalli Industrial Area,
Mysore - 570018
Karnataka.

Love your Job. But dont fall in love with your Company !


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] How to solve SSS triangle?-Solution

2005-11-22 Thread Pandian

Thank u Danny Kodicek...
and i am presenting the solution to solve SSS triangle...
/SOLVE TRIANGLE ///
///pass the instance names of there movieclips on the stage
//this function returns a Solution Object
//Solution object has:
//a-side1
//b-side2
//c-side3
//A-angle1
//B-angle2
//C-angle3
function solveTriangle(a_mc, b_mc, c_mc) {
   a = distance(b_mc, c_mc);
   b = distance(c_mc, a_mc);
   c = distance(a_mc, b_mc);
   //find Angle A
   var A = (Math.pow(b, 2)+Math.pow(c, 2)-Math.pow(a, 2))/(2*b*c);
   A = Degree(Math.acos(A));
   //trace(A);
   /find Angle B
   var B = (Math.pow(a, 2)+Math.pow(c, 2)-Math.pow(b, 2))/(2*a*c);
   B = Degree(Math.acos(B));
   //trace(B);
   var C = 180-(A+B);
   //trace(C);
   A = Math.round(A);
   B = Math.round(B);
   C = Math.round(C);
   var solution = {a:a, b:b, c:c, A:A, B:B, C:C};
   return solution;
}
function distance(p1, p2) {
   //returns pixels
   var dx = p2._x-p1._x;
   var dy = p2._y-p1._y;
   var dis = Math.pow(dx, 2)+Math.pow(dy, 2);
   var dis = Math.sqrt(dis);
   return dis;
}
function Degree(rad) {
   return (180/Math.PI)*rad;
}
function Radian(deg) {
   return (Math.PI/180)*deg;
}
end//
enjoy
-Pandian
Danny Kodicek wrote:




I am having 3 movie Clips named point1_mc, point2_mc, point3_mc in the
stage. They are arranged  in such a way to form a triangle...
Now how can i get those 3 angles and sides formed by these points.?



Sides are given by the lengths of the vectors between the points (eg: 
x = point1_mc._x - point2_mc._x, y = point1_mc._y - point2_mc._y, so 
side length =sqrt(x*x + y*y) )


Once you have these sides, you can use the cosine rule to find the 
angles: If you know the three sides a,b,c, the angle A between the 
sides b and c is given by a*a = b*b + c*c - 2*b*c*cosA.


To get acos(A), you need to use atan(A): acos(A)=atan(A/sqrt(1 - A*A))

Best
Danny
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders



___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] How to solve SSS triangle?

2005-11-22 Thread ryanm
I am having 3 movie Clips named point1_mc, point2_mc, point3_mc in the 
stage. They are arranged  in such a way to form a triangle...

Now how can i get those 3 angles and sides formed by these points.?


   With a high school geometry textbook? ;-)

Law of cosines: c^2 = a^2 + b^2 - 2ab*Cos(q)
Where a, b, and c are the sides, and q is the angle opposite c

ryanm
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] How to solve SSS triangle?

2005-11-21 Thread Danny Kodicek



I am having 3 movie Clips named point1_mc, point2_mc, point3_mc in the
stage. They are arranged  in such a way to form a triangle...
Now how can i get those 3 angles and sides formed by these points.?


Sides are given by the lengths of the vectors between the points (eg: x = 
point1_mc._x - point2_mc._x, y = point1_mc._y - point2_mc._y, so side length 
=sqrt(x*x + y*y) )


Once you have these sides, you can use the cosine rule to find the angles: 
If you know the three sides a,b,c, the angle A between the sides b and c is 
given by a*a = b*b + c*c - 2*b*c*cosA.


To get acos(A), you need to use atan(A): acos(A)=atan(A/sqrt(1 - A*A))

Best
Danny 


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


[Flashcoders] How to solve SSS triangle?

2005-11-21 Thread Pandian
I am having 3 movie Clips named point1_mc, point2_mc, point3_mc in the 
stage. They are arranged  in such a way to form a triangle...

Now how can i get those 3 angles and sides formed by these points.?
Thank u
-Pandian

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders