Angular Velocity issues


#1

There is an issue where the values I enter into the script for Angular Velocity get changed.

For example I run this line in a script

    angularVelocity: {x: 0, y: 0, z: 1.0},

and yet the entity produced has the values

Angular Velocity
Pitch 0.0 Yaw 0.0 Roll 57.30

Are we having some angular velocity problems? Because this code used to work some time ago.

Thx.


#2

The script data is being interpreted as radians, but displayed in degrees. 1.0 radians is equal to 57.3 degrees


#3

Yes I thought the figure was familiar.
So clearly there is a problem somewhere, can I take it that you have taken it on and there will soon be a fix?
Or should I open worklist job?


#4

BUMP:

This is still an issue, degrees are still being converted to radians.


#5

The degree versus radians thing is probably decided upon already. Meaning, if they switch to use one over the other, complaints come in from the opposite side.
Just use this in your code:

function rad2deg(theta){ return  (theta * (180/Math.PI)) }
function deg2rad(theta){ return (theta * (Math.PI/180)) }

#6

@AlphaVersionD I am really not sure what you mean by “Complaints come from the opposite side”.

Whats happening here is simply an error, not a choice. when I type a certain angle in as pitch, yaw, roll in degrees, thats what I expect to get back. I dont expect the system to arbitrarily add a function that converts my answer to a different format.

If I write a script that sets my angular velocity to

angularVelocity: {x: 0, y: 0, z: 1},

and the result is

angularVelocity: {x: 0, y: 0, z: 57.3},

That is simply a bug in the scripting engine.

if I start adding workarounds to my script then they fix the bug, then my script is wrong.
So lets fix the bug.


#7

AH! A mis-interpretation of the situation on my part.

What I was trying to describe was a general decision to store angular data in degrees OR radians for the engine. What you’ve shown is 1 in 57.3 out.


#8

@Adrian Is this still a problem? I can’t seem to reproduce it with latest build.


#9

Yes.
Run this script, then click the object and look at its Angular velocity values.

var test = {
        type: “Box”,
        position: MyAvatar.position,
        dimensions: {x:4.0, y: 1.0, z: 1.0},
        angularVelocity: {x: 1.0, y: 0, z: 0},
        angularDamping: 0,
        lifetime: 60    
    }
    Entities.addEntity(test);


#10

Ah, OK. … Internally (and in scripts) angularVelocity is in radians per second, but when displayed in the entity editor it is in degrees per second.

So if you set one of the rotation axis values to 1.0 rads/sec by script it’s displayed as 57.3 deg/sec in the entities editor.

And if you set one of the rotation axis values to 57.3 deg/sec in the entities editor the value retrieved by script via Entities.getEntityProperties() is 1 rad/sec.

I.e., looks like it’s working OK.


#11

Hmm, Yes we already established that.
I respect your reply but I say its not working properly.

We need uniformity, it should be one or the other, if its going to be radians then lets make the properties panel display radians.

This has changed, I have several scripts written some time ago that worked as expected when written, now the values are read as radians and the script doesnt work right. I can work in degrees or radians thats not the issue.
I dont want to go and change all my scripts just to find out that it was a bug and will be fixed, rendering my workarounds redundant.
I need to know if we are now working in radians and someone has to update the properties panel,
or,
it is a bug and somebody needs to fix the bug.

@ZappoMan @Jherico can we get a ruling on this please?


#12

What David is say is correct and what we intentionally implemented.

I understand your concerns Adrian. I’ve argued in the past that radians/second is hard to understand for the average user and so it did t make sense to use radians in the UI.

Let me talk with the other developers and in particular Philip who was involved in this decision.


#13

@ZappoMan thanks for the clarification

I completely agree, yes please bring this up.

I have the answer I was looking for. We are in radians, regardless of what the UI says, I can now modify my scripts with confidence that this is the format going forward.

I was only confused because this has changed and I needed to be sure the change was permanent and not just a bug.

I can see some uniformity: for example rotation is scripted in quaternians but the UI displays in degrees. We certainly dont want quaternians in the UI. Perhaps this is the thinking for angular velocity also.

Thank you all for the input.