ActionScript 3.0 :: Convert Slope To Degrees?

Jul 7, 2011

I'm having trouble with this mainly because Flash's Math.atan() doesn't give the same results as my TI-83's tan^-1 function.

If I have a line with a positive rise and run for the slope and use tan^-1( (the slope) ) on my calculator, I get a value between 0 and 90, with 0 being a horizontal line and 90 a vertical line. A negative numerator with a negative denominator for the slope puts it in quadrant 4 where tan^-1(slope) gives 0 to -90 values, again with 0 being horizontal and -90 being vertical.

Putting the slope of the blue line into tan^-1() would give a value of about 80 degrees, while the red line would calculate to about -50 degrees. The rotation property Flash uses rotates objects clockwise and can range from 0-360. Using the -90 to 90 values and figuring out if the rise and run of the slope are positive or negative, I can determine which quadrant the line is in and calculate the degrees.

However, this so far is not possible for me because Math.atan() gives odd results.

A practical application for this knowledge would be a player in a game throwing spears from (0,0) to the mouse x,y. The slope would take care of the trajectory of the spears, however if your spear sprite is a spear flat and facing toward the right, you need to rotate it appropriately from 0-360.

View 1 Replies


Similar Posts:


ActionScript 2.0 :: X, Y To GPS - Convert A Decimal Value (like 10.25) Back To Degrees And Hours?

Apr 18, 2006

if I have a map of say, Wisconsin, and I know what the Latitude coords (degrees, hours, minutes) of the top and bottom of the map, and I know how many pixels tall the map is, then I should be able to convert, with math, degrees:hours:mins to pixels. (same thing with longitude, but lets just focus on one way first)

I would first find out how may hours (minutes would be over kill for my app) there are to a pixel. Thats pretty easy. But this gives me a decimal number. How do i convert a decimal value (like 10.25) back to degrees and hours (in other words, how do i make .25 a "60" based value)? Ultimately, i want the user to be able to input coords in the form of degrees, hours, mins. Then convert that to X, Y (to place a marker on the map).

Has any one had experience with this or know how to do this?

View 3 Replies

Flash :: Flex - 3D - AS3 - Convert Degrees Of Rotation To Visible Height

Nov 5, 2009

I need to know what the visible height of a display object will be after I change it's rotationX value. I have an application that allows users to lay out a floor in 3D space. I want the size of the floor to automatically stretch after a 3D rotation so that it always covers a certain area. EDIT: I guess what I am really trying to do is convert degrees to pixels.

On a 2D plane say 100 x 100 pixels, a -10 degree change on rotationX means that the plane has a gap at the top where it is no longer visible. I want to know how many pixels this gap will be so that I can stretch the plane. In Flex, the value for the display objects height property remains the same both before and after applying the rotation, which may in fact be a bug.

EDIT 2: There must be a general math formula to work this out rather than something Flash/Flex specific. When viewing an object in 3D space, if the object rotates backwards (top of object somersaults away from the viewer), what would the new visible height be based on degrees of rotation? This could be in pixels, metres, cubits or whatever.

View 5 Replies

ActionScript 2.0 :: MX Jumping On A Slope?

Nov 19, 2010

I have this rather cool code for a _mc on a slope. The only problem I am having is making the sprite.mc change states/animation when the sprite.mc is jumping.here's the code I have:

onClipEvent(load){
speed = 5;
gravity = 0;
r = _height/2; //radius

[code]....

View 1 Replies

ActionScript 2.0 :: Rebound Angle On Slope?

Jan 22, 2011

I have the xspeed and yspeed of a round ball, xspeed is distance ball moves to the right each frame and yspeed distance ball moves down each frame.I have 3 different gradients of slopes, one is at 15 degrees off the horizontal.How can I calculate the xspeed and yspeed of the ball after a collision with, for instance, the 15 degree slope.

View 2 Replies

ActionScript 3.0 :: Drawing Slope Of A Line?

Jan 27, 2011

I'm trying to create a simple graph showing the stock trends for the past few days. In the x axis I have the dates and in the y axis I have the stock value. I have to do this dynamically and I think I can figure it out, but I need help with something else: I need to be able to (dynamically) draw the slope of the line as the user clicks on a point... something like in www_calculusapplets_com/twicediff.html except that instead of having the slider the user will click on the actual line.

View 6 Replies

ActionScript 2.0 :: Rotating MovieClip On Slope?

Apr 21, 2007

How can I rotate a movieclip so that when I move it, it will rotate slightly depending on the angle of the ground. The only thing I can relate this too is the old school sonic games. How would I find the curve of the ground and apply it the moving character?

View 8 Replies

ActionScript 3.0 :: Slope Detection In Platformer

Jun 15, 2010

I have an art based platformer with a movie clip that is basically a triangle shaped object that serves as the slope.My problem is in the collision detection with the slope. Here's the code that i currently have - [code]This basically places the rectangle shape that serves as the main player (_rec) along the slope and increments its y position based on it's current x position. The reg point of the slope is on the bottom left.The problem is that this code comes into effect even if _rec is jumping over the triangle because of the square shaped hitbox of the slope. Also, for the same reason, I cannot jump while on the slope itself.I know of a way to rotate the character based on the incline in the ground but I don't really like that idea. The character should stay vertical at all times. I really don't want to do a tile based version as I have a lot of art already designed, it's only the ground objects that are basic shapes.

View 1 Replies

ActionScript 3.0 :: Find Slope / Angle Of A Drawn Line?

Jun 20, 2010

At the moment I am using two mini objects within the line to calculate the slope of the line I have.

I was wondering if there was some easy function within as3 to find the slope of a line that had been drawn out, if not... I suppose I have my own theories on how to do it, such as checking for hit tests in a circle until I find the line.

View 5 Replies

ActionScript 3.0 :: Flash Finding Best Fit Slope Of A Bitmap Surface

Jan 24, 2012

I was wondering if anyone knows of a way to isolate the pixels that are adjacent to a certain color pixel in a BitmapData. For example, if there was a BitmapData that looked something like this:[code]I was wondering if there was a proven and efficient way of doing this, because I am trying to make a collision engine of sorts that can give me the collision normal of the best fit slope of a given bitmap image. In the scenario of the last example, the slope would be 1/1, or -45 degrees. The way I have it now, I am isolating the adjacent pixels by blurring the entire image, looping through all of the pixels, and storing the gray ones in an array. from there I can determine the best fit slope of the surface of the image. The only thing is that this seems like a lot of work for the CPU. Is there a better way to isolate the black pixels adjacent to white ones than blurring the image and looping through every pixel?

View 12 Replies

ActionScript 3.0 :: How To Make Ball Roll Down Slope / Fall And Bounce

Jul 5, 2009

I followed this tutorial to make a bouncing ball in flash. Its AS2 so it took me some time to make it work in AS3 Now I want to make the ball roll down a slope, fall and bounce when it hits the ground. I have attached my .fla.

View 1 Replies

Actionscript 3 :: Drawing An Arrow At The End Point Of The Line Using Line Slope?

Jan 9, 2012

I am developing a white board application which allows the user to draw line with arrow head (some like Microsoft Word line with arrow feature). I am using graphics property along with lineTo() method to draw a line. Now i have to draw a angular arrow on the last point of line. I am drawing the arrow by connecting the points around last points. As 360 line can pass through this point and each line can have a different angle of arrow.

View 1 Replies

ActionScript 2.0 :: Equation Generate To Graph \ Show A Slope Graph?

Jan 26, 2010

School Project with the following actionscript in Flash 8, I want to show a slope graph? What code to add to make slope graph work?

/*var orig_x:Number;
var orig_y:Number;
orig_x = (plane_mc._x)+(plane_mc._width/2);

[code].....

View 0 Replies

F8 :: Spin A Product 360 Degrees?

Nov 1, 2007

Wanting to spin a product 360 degrees.

View 1 Replies

Php :: View Images In 360 Degrees?

Jun 14, 2011

I would like to rotate an image in 360 degrees, like this site.

I have a site, where the users can upload images and view them in 360 degrees.

View 3 Replies

ActionScript 3.0 :: Rotate 90 Degrees?

Jan 18, 2009

I want to write a function to make a movie clip rotate 90 degrees but I can't figure it out. I'm using as3

View 1 Replies

ActionScript 2.0 :: Get The AngleA In Degrees?

Apr 7, 2005

I have this: cosA=0.76545842217484 How do I write the code to get the angleA (in degrees)?

View 9 Replies

ActionScript 2.0 :: Rotating Text 90 Degrees?

Mar 26, 2009

I am trying to rotate this text 90 degrees. I've read that you're supposed to embed the text....and I've tried that and the text just vanishes. I've also tried to set my own text format, but the problem persists.

Code:
var tf:TextFormat = new TextFormat();
tf.font = "Verdana14B";
tf.size = 14;[code]...........

View 1 Replies

Professional :: Objects Moving 360 Degrees?

Feb 1, 2010

i'm not quite sure which forum to use, so therefore I post this discussion here. I want to animate an object that is turning 360 degrees around.

[Code]...
 
It does'nt need any navigation like this example, but it's going to just an animationmovie.This animation is going to be viewed on a widescreen tv. How do I make the animation fit the screen? I'm not sure which resolution the animation must be. I guess this has to match the resolution of the tv. But is it just as simple as changing the flash file settings in 1920 x 1080?

View 6 Replies

ActionScript 3.0 :: Scrolling Of Images - 360 Degrees

Jan 4, 2010

I want to scroll these image 360 degrees. Right now i can go end to end but it will not recylcle the image. Is there any code out there that will do this? How would i fix the code i have to accomplish this? Working swf file [URL] Source code link
[URL]

[Code]....

View 1 Replies

ActionScript 3.0 :: Rotation Troubleshoot: Where Is 270 Degrees?

Oct 19, 2010

I am rotating an object by incrementing in 90 degrees,however after 180degrees it rotates to -90...then it can't quite make it's mind up if it should go to -180, or 0, which should be the same thing? (except it messes up my if statements down the line)(by that I mean, sometimes it will go back to 0, and sometimes it will switch to -180??)Where is 270, and for that case, 360?

View 2 Replies

ActionScript 3.0 :: Converting Degrees To Radians

Apr 6, 2011

I have a program which must convert degrees to radians every frame and use this value to change a variable. After a while, I notice that the variable becomes way different than what it should be, because of the slight inaccuracy when converting degrees to radians (I multiply to value by pi/180). I was wondering if there is a more accurate way to convert or maybe a way to use Math.cos() and Math.sin() with degrees.

View 4 Replies

ActionScript 2.0 :: Rotating Object By Set Degrees

Apr 8, 2004

I need to get a certain object to rotate by set degrees (my navigation for this project is organized on a wheel--6 sections on the wheel), and I would like to have buttons that tell this object to smoothly rotate by set degrees (intervals of 60 degrees in this case).

What I have in mind are 5 buttons that control the rotation:
1. 120 deg. ClockWise
2. 60 CW
3. 60 CCW
4. 120 CCW
5. 180 CCW

View 7 Replies

ActionScript 2.0 :: Rotating MovieClip From 0 To 180 Degrees?

Jan 23, 2007

I've created some code that rotates an arrow up or down when the user clicks on it, depending on whether the timeline is on frame 1 or 5. The problem I am encountering is that rather than rotating visually, it just flips to the correct degree (in this case, 0 or 180).

Code:
function turndown():Void{
for(i=0; i<16; i++){
this.upDownMC._rotation += 11.25;
}} function turnup():Void{
[Code] ......

View 5 Replies

ActionScript 3.0 :: Rotate A TxtField To 270 Degrees?

Jul 6, 2011

how do i simply rotate a txtField to 270 degrees?

when i do this my text disappears:

txt.rotation = 270;

View 5 Replies

ActionScript 2.0 :: (MX): Rotating An Object By Set Degrees?

Apr 8, 2004

getting a certain object to rotate by set degrees (my navigation for this project is organized on a wheel--6 sections on the wheel), and I would like to have buttons that tell this object to smoothly rotate by set degrees (intervals of 60 degrees in this case).What I have in mind are 5 buttons that control the rotation:1. 120 deg. ClockWise2. 60 CW3. 60 CCW4. 120 CCW5. 180 CCW

View 6 Replies

ActionScript 2.0 :: Rotate Stick 45 Degrees When Click It?

Mar 17, 2009

i have a stick id like to drag and rotate. ive followed a nice tutorial for it, and it works fine but i only want to rotate my stick 45 degrees when i click it. the tutorial i followed only alows my to rotate 180 degrees ??this is the code ive used

Code:
handle.grip.onPress = function() {
handle.onMouseMove = function() {

[code].....

View 3 Replies

ActionScript 3.0 :: Capture Total Degrees Rotated?

Apr 13, 2011

I am using Senocular transform tool and I have an object on the stage which I can rotate freely using the mouse. What I want to do is "capture" the total degrees I am rotating the object and write in a a text box. For example, if I will rotate the object clockwise 3 times, the text box will show 1080 (360 * 3), if I will rotate the object counter clockwise 1.5 times the text box will show -540 (360 * -1.5).

View 8 Replies

Rotate A Movieclip 360 Degrees Over A Period Of Time?

Aug 9, 2010

How do I rotate a movieclip 360 degrees over a period of time?  Can I use "new tween" ?  I am trying to rotate the movieclip while it is moving from position y to y+50 (this is done using new tween)

View 1 Replies

Professional :: Rotating Mc 360 Degrees Using The 3D Rotation Tool

Nov 30, 2010

I'm new to Flash and I'm having trouble rotating my mc 360 degrees using the 3D Rotation Tool. I can rotate it 180 degrees, right side coming forward, but when I attempt to rotate it back to its original position, it doesn't continue the rotation in the same direction (right side coming forward). So instead of apearing to rotate completely, it looks like it rotates half way, stops, and rotates back (left side comes forwards). Probably an easy solution, but as I said, I'm new.

View 9 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved