Go Back   kirupaForum > Flash > ActionScript 1.0/2.0

Reply
 
Thread Tools Display Modes
Old 10-05-2009, 04:04 PM   #1
thawfeekyahya
Registered User
Finding the angle of a movie clip

Wat's the difference between to find angles of two points which is
(x1,x2) and the other point be (_xmouse,_ymouse).

To find the angles we subtract from one point to the other

like
method 1:

target x = (_xmouse - mc._x)
target y= (_ymouse - mc._y)

method 2:

target x = (mc._x - _xmouse)
target y = (mc._y - ymouse)

wat's the difference between with this two methods

wen i implement with this target x and y values to Math.atan2(y,x)

i am getting different results

does this two have any major difference????

i get the error especially in this program--------->
_________________________________


var spring:Number = 0.1;
var friction:Number = 0.9;
var springLength:Number = 75;
var vx:Number = 0;
var vy:Number = 0;

onEnterFrame = function () {
var dx:Number = ball._x - _xmouse;
var dy:Number = ball._y - _ymouse;
var angle:Number = Math.atan2(dy, dx);
var targetX:Number = _xmouse + Math.cos(angle) * springLength;
var targetY:Number = _ymouse + Math.sin(angle) * springLength;
vx += (targetX - ball._x) * spring;
vy += (targetY - ball._y) * spring;

vx *= friction;
vy *= friction;
ball._x += vx;
ball._y += vy;

clear();
lineStyle(1, 0, 100);
moveTo(ball._x, ball._y);
lineTo(_xmouse, _ymouse);
};
thawfeekyahya is offline   Reply With Quote

Sponsored Links (Guests Only) - Register | Need Help?
 

Old 10-05-2009, 05:51 PM   #2
cbeech
...something...
Location frozen tundra

Posts 675
the difference in the two is, considering pointA and pointB is that if you subtract pointA values from pointB values you get the angle from the vertex at pointB - whereas if you subtract pointB from pointA you get the angle from the vertex at pointA.

rem: Math.atan2 will return a value in Radians.
cbeech is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:19 PM.

SUPPORTERS:

kirupa.com's fast and reliable hosting provided by Media Temple. flash components
Creative web apps. Make your own free flash banners and photo slideshows.
Check out the great, high-quality flash extensions. Buy or sell stock flash, video, audio and fonts for as little as 50 cents at FlashDen.

Flash Transition Effects

Flash Effect Tutorials

Digicrafts Components
Flash effects. Art without coding. Upload, publish, deliver. Secure hosting for your professional or academic video, presentations & more. Screencast.com
Streamsolutions Content Delivery Networks Flipping Book - page flip flash component.
Flash-Gallery.com - Get your flash photo gallery (flash component or swf gallery Learn how to advertise on kirupa.com
 

cdn
content delivery network (cdn)

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd. Copyright 2010 - kirupa.com Copyright 2010 - kirupa.com