• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Extract only true degrees from rotation

New Here ,
Jan 11, 2017 Jan 11, 2017

Copy link to clipboard

Copied

Hi Guys,

I need to find a way to extract true degrees from the rotation transform. So instead of reading 1x-90 or 2x270, It just needs to read the 270 degrees part.

So if somethings continuously rotates, if you go beyond 360, it goes to 1x1 on the display or 361 if you read it out in expressions. But I only need to now if something is beyond 180 degrees or not, everytime it rotates.

So if it says 1x179, then it needs to understand that it is 179 and therefore not greater then 180 or not beyond the half of the circle, but it reads this of course at (1x360+179) 539, which IS greater then 180. So my if-then doesn't detect when its in the second half of the circle past one rotation.

Is there anyone who has discovered a function or some sort that does that?

Kind regards,

Marten.

TOPICS
Expressions

Views

1.6K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Enthusiast , Jan 11, 2017 Jan 11, 2017

My expression simply always returns 0-360. If you want to do something after like check for greater than 180 you could add it after this:

a = thisComp.layer(1).transform.rotation;

if (a >= 0) b = a - (Math.floor(a / 360) * 360);

else b = 360 + (a - (Math.ceil(a / 360) * 360));

if (b....and so on

Votes

Translate

Translate
Enthusiast ,
Jan 11, 2017 Jan 11, 2017

Copy link to clipboard

Copied

You could use something like this:

a = thisComp.layer(1).transform.rotation;

if (a >= 0) a - (Math.floor(a / 360) * 360);

else 360 + (a - (Math.ceil(a / 360) * 360));

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 11, 2017 Jan 11, 2017

Copy link to clipboard

Copied

Thanks for your reply. I tried running the value through your suggestion, but it doesn't work. I do not understand what the instruction set for itself mean's so maybe I'm doing it wrong here.

I had:

turn = transform.rotation

if (turn > 180){

[180];

}else{[0]; }

With your suggestion:

a = transform.rotation;

if (a >= 0) a - (Math.floor(a / 360) * 360);

else 360 + (a - (Math.ceil(a / 360) * 360));

turn = a

if (turn > 180){

[180];

}else{[0]; }

It still doesn't detect only the absolute degrees on the a 360 degrees scale. It works only the first time around, and then it keeps saying it's more then 180. (so 361 is of course more than one 180, but on an absolute 360 scale it is 1 again, which is less, which should test false)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jan 11, 2017 Jan 11, 2017

Copy link to clipboard

Copied

My expression simply always returns 0-360. If you want to do something after like check for greater than 180 you could add it after this:

a = thisComp.layer(1).transform.rotation;

if (a >= 0) b = a - (Math.floor(a / 360) * 360);

else b = 360 + (a - (Math.ceil(a / 360) * 360));

if (b....and so on

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 11, 2017 Jan 11, 2017

Copy link to clipboard

Copied

This works! Thanks!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 12, 2017 Jan 12, 2017

Copy link to clipboard

Copied

LATEST

you can also write this a bit more compact:

a = thisComp.layer(1).transform.rotation;

b = (a%360 + 360) % 360;

// now b is between 0 and 360  (including 0 and excluding 360)

Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines