e.normal to degrees in 360
19 posts • Page 1 of 1
e.normal to degrees in 360
I just need a script to get the degrees of the angle in 360 degrees.
I keep searching for this but all i can find is how to get e.normal to degrees up to 180 and then goes to negative degrees.
Thank you
I keep searching for this but all i can find is how to get e.normal to degrees up to 180 and then goes to negative degrees.
Thank you
- fox11trot
- Posts: 62
- Joined: Tue Sep 01, 2009 7:25 am
Re: e.normal to degrees in 360
I'm on my iPod right now, so this is off the top of my head.
Whatever you were using to get the angle to 180, e.normal(0) or e.normal(1) or a manipulation of them, use the variable I previously said. If you could post what you currently using that would be of great help.
- Code: Select all
scene.my.rad2deg=(n)=>{n * math.pi/180}
Whatever you were using to get the angle to 180, e.normal(0) or e.normal(1) or a manipulation of them, use the variable I previously said. If you could post what you currently using that would be of great help.
-
standardtoaster - Posts: 606
- Joined: Mon Aug 31, 2009 7:57 pm
Re: e.normal to degrees in 360
heres what i was using before
- Code: Select all
{(math.acos(e.normal(0)) * (180 / math.pi)) > 90} ? {e.geom.anglen = (math.acos(e.normal(1)) * (180 / math.pi))} : {e.geom.anglen = (-(math.acos(e.normal(1)) * (180 / math.pi)))};
- fox11trot
- Posts: 62
- Joined: Tue Sep 01, 2009 7:25 am
Re: e.normal to degrees in 360
Try using math.pi/180 instead of 180/math.pi
-
standardtoaster - Posts: 606
- Joined: Mon Aug 31, 2009 7:57 pm
Re: e.normal to degrees in 360
hmm that gives me some random decimal for the angle
- fox11trot
- Posts: 62
- Joined: Tue Sep 01, 2009 7:25 am
Re: e.normal to degrees in 360
Sorry about that. Here it is, fixed, as far as I know.
How's that?
- Code: Select all
{(math.acos(e.normal(0)) * (180 / math.pi)) > 90} ? {e.geom.anglen = (math.acos(e.normal(1)) * (180 / math.pi))} : {e.geom.anglen = (180 + (math.acos(e.normal(1)) * (180 / math.pi)))};
How's that?
-
standardtoaster - Posts: 606
- Joined: Mon Aug 31, 2009 7:57 pm
Re: e.normal to degrees in 360
Actualy, it seems to be that that code doesn't go from 0 - 360, it goes from 0 - 180, and 360 - 181 in a circle. I think it should be this. just add a negative 1
That should work better.
- Code: Select all
{(math.acos(e.normal(0)) * (180 / math.pi)) > 90} ? {e.geom.anglen = (math.acos(e.normal(1)) * (180 / math.pi))} : {e.geom.anglen = (180 + (math.acos((-1) * e.normal(1)) * (180 / math.pi)))};
That should work better.
-
Versieon - Posts: 375
- Joined: Tue Sep 01, 2009 4:45 pm
Re: e.normal to degrees in 360
yeah i tried it and u were right
i will try versions code
THANK YOU
i will try versions code
THANK YOU
- fox11trot
- Posts: 62
- Joined: Tue Sep 01, 2009 7:25 am
Re: e.normal to degrees in 360
Versieon wrote:Actualy, it seems to be that that code doesn't go from 0 - 360, it goes from 0 - 180, and 360 - 181 in a circle. I think it should be this. just add a negative 1
That should work better.
Why so complicated?
- Code: Select all
scene.my.angle = math.acos(e.normal(0)) * 180/math.pi ; e.normal(1) < 0 ? {scene.my.angle = 360 - scene.my.angle} : {}
-
KarateBrot - Posts: 825
- Joined: Mon Aug 31, 2009 7:32 pm
- Location: Germany
Re: e.normal to degrees in 360
standardtoaster wrote:I'm on my iPod right now, so this is off the top of my head.
- Code: Select all
scene.my.rad2deg=(n)=>{n * math.pi/180}
Whatever you were using to get the angle to 180, e.normal(0) or e.normal(1) or a manipulation of them, use the variable I previously said. If you could post what you currently using that would be of great help.
BUT: what does the (n) in the script? what is is for ?
scene.my.rad2deg = (n) => {n*math.pi / 180} so i mean the n of
^
that one (the (n) i whas talking about
and what does e.normal mean in everything of the script? why is it so important
- jessebax129
- Posts: 34
- Joined: Tue Jan 05, 2010 6:32 pm
Re: e.normal to degrees in 360
n is a parameter. You use it like this: scene.my.rad2deg(math.pi/4) e.normal is the normal of an object. For more information on normal go here.
-
standardtoaster - Posts: 606
- Joined: Mon Aug 31, 2009 7:57 pm
Re: e.normal to degrees in 360
for n you put in the angle you want to convert from radians to degrees. n is just the variable for it.
-
KarateBrot - Posts: 825
- Joined: Mon Aug 31, 2009 7:32 pm
- Location: Germany
Re: e.normal to degrees in 360
KarateBrot wrote:for n you put in the angle you want to convert from radians to degrees. n is just the variable for it.
can't you just say:
- Code: Select all
angle1 = (n)=> {360} ??????
- jessebax129
- Posts: 34
- Joined: Tue Jan 05, 2010 6:32 pm
Re: e.normal to degrees in 360
That would not work for this. You just made a function that says angle1(n) = 360! What Scene.my.rad2deg does is take n, which is the parameter, ie. the thing you replace it with, and then return the radians as degrees. Scene.my.rad2deg(Scene.my.angle1) will tell you what Scene.my.angle1 would be if it was in degrees.
-
standardtoaster - Posts: 606
- Joined: Mon Aug 31, 2009 7:57 pm
Re: e.normal to degrees in 360
jessebax129 wrote:can't you just say:ANGLE1 IS THE VARIABLE THAT I USE FOR THIS
- Code: Select all
angle1 = (n)=> {360} ??????
Do you know something about mathematical functions? They work like functions in algodoo.
For example:
The mathematical notation is f(x) = x²
In Algodoo this would be scene.my.f = (x) => { x^2 }
- - - - -
And now if you want to let Algodoo calculate scene.my.f for any x you type in scene.my.f(x) where x is your desired value of which algodoo has to calculate the square from.
Mabe it's more clear if you know about this.
-
KarateBrot - Posts: 825
- Joined: Mon Aug 31, 2009 7:32 pm
- Location: Germany
Re: e.normal to degrees in 360
okay but can i use instead of scene.my.rad2deg = (n) => {............} to-->> angle1= (n) => {......} ???
- jessebax129
- Posts: 34
- Joined: Tue Jan 05, 2010 6:32 pm
Re: e.normal to degrees in 360
You can, although that would be another function. Angle1(n) would return something.
-
standardtoaster - Posts: 606
- Joined: Mon Aug 31, 2009 7:57 pm
Re: e.normal to degrees in 360
You can use any name you want. it's just a name. the function is the thing behind "angle1 =". but make sure to use custom variables! otherwise this doesn't work on other computers and only on your own one. so always make sure to put scene.my. in front of it
Instead of:
angle1 = ...
You have to use:
scene.my.angle1 = ...
Instead of:
angle1 = ...
You have to use:
scene.my.angle1 = ...
-
KarateBrot - Posts: 825
- Joined: Mon Aug 31, 2009 7:32 pm
- Location: Germany
19 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 6 guests