0
Flash Math
Contributor
,
/t5/animate-discussions/flash-math/td-p/245419
Aug 23, 2007
Aug 23, 2007
Copy link to clipboard
Copied
Any good ActionScript mathematicians out there?
I keep getting "NaN" on this value, but should not be.
lambda = (Math.sqrt(((x*2)+(y*2)) - R0) * (1/R1));
where:
x = x coordinate
y = y coordinate
R0 = radius of a circle
R1 = radius of another circle
With this variable, I get a mix of valid numeric values and sometimes "NaN". It appears that the formula is valid, but that some of the values are going beyond what Flash can recognize.
What limitations does ActionScript have with number generation?
I keep getting "NaN" on this value, but should not be.
lambda = (Math.sqrt(((x*2)+(y*2)) - R0) * (1/R1));
where:
x = x coordinate
y = y coordinate
R0 = radius of a circle
R1 = radius of another circle
With this variable, I get a mix of valid numeric values and sometimes "NaN". It appears that the formula is valid, but that some of the values are going beyond what Flash can recognize.
What limitations does ActionScript have with number generation?
TOPICS
ActionScript
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/animate-discussions/flash-math/m-p/245420#M272634
Aug 23, 2007
Aug 23, 2007
Copy link to clipboard
Copied
The only place I see would be a problem is if any of these
variables were undefined, or of type text because they were coming
from a text field (or XML or some such), or if R1 was equal to
zero. You can add this line immediately before lambda.
trace([x,y,R0,R1]);
Paste the response.
trace([x,y,R0,R1]);
Paste the response.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

/t5/animate-discussions/flash-math/m-p/245421#M272635
Aug 23, 2007
Aug 23, 2007
Copy link to clipboard
Copied
Most likely, ((x*2)+(y*2)) - R0 < 0. Flash can't square
root negative numbers.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/animate-discussions/flash-math/m-p/245422#M272636
Aug 23, 2007
Aug 23, 2007
Copy link to clipboard
Copied
D'oh! I should have seen that coming. Yeah.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Community Expert
,
/t5/animate-discussions/flash-math/m-p/245423#M272637
Aug 23, 2007
Aug 23, 2007
Copy link to clipboard
Copied
beyond that being the root of a negative number, when he's
getting NaN:
x*2 +y*2 should probably be x*x + y*y.
x*2 +y*2 should probably be x*x + y*y.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Guru
,
LATEST
/t5/animate-discussions/flash-math/m-p/245424#M272638
Aug 24, 2007
Aug 24, 2007
Copy link to clipboard
Copied
interesting, this might explain why a few of my pythagorean
calcs don't always work too. So other than tracking the quad, and
using Math.abs, how could one go about making this calc on a
cartesian system? use other trig, I suppose, or Point.distance
prop?
EDIT: strike that 🙂
EDIT: strike that 🙂
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

