• Global community
• Language:
• Deutsch
• English
• Español
• Français
• Português
• 日本語コミュニティ
Dedicated community for Japanese speakers
• 한국 커뮤니티
Dedicated community for Korean speakers
Exit
• Re: Why does the shape randomly rotate 180deg from...

# Why does the shape randomly rotate 180deg from where it is expected

Participant ,
Feb 16, 2023 Feb 16, 2023

Copied

As per title, why’d  does the arrowhead shape rotate 180 from the expected orientation randomly?

How can I fix this to keep the orientation consistent?

I have a line path with the ends following nulls.. so I can easily select the null and move the line endpoints.

I have an expression on the Shape (triangle) postion and rotation to position and orient it at the end of the line.

Position the arrow at end of the line:

shapeGroup = thisComp.layer("Shape Layer 1").content("The Line");

myPath = shapeGroup.content("Path 1").path;

endPt = myPath.pointOnPath(1);

Orient the arrow to the end of the line:

shapeGroup = thisComp.layer("Shape Layer 1").content("The Line");

myPath = shapeGroup.content("Path 1").path;

tg = myPath.tangentOnPath(1.0);

TOPICS
Error or problem , Expressions

Views

756

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 Expert , Feb 16, 2023 Feb 16, 2023

My guess is that it's probably something wierd about calculating the tangent right on the end of the line. I'd try changing this:

``tg = myPath.tangentOnPath(1.0);``

to this:

``tg = myPath.tangentOnPath(.99);``

and see if that helps.

7 Replies 7
Community Expert ,
Feb 16, 2023 Feb 16, 2023

Copied

My guess is that it's probably something wierd about calculating the tangent right on the end of the line. I'd try changing this:

``tg = myPath.tangentOnPath(1.0);``

to this:

``tg = myPath.tangentOnPath(.99);``

and see if that helps.

Report

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

Copied

@Dan Ebberts  - interesting.. seems to do the trick.  Thx, much!

Report

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

Copied

At certain angles the result will simply be zero. Your demo shows around 30-ish degrees, which would track. Simple math.

Mylenium

Report

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

Copied

Thanks, @Mylenium  - I'm sure there is a simple mathematical explaination, it has been ages since I've flexed my trig, but, respectfully, I don't think it has to do with the resulting angles in this case.  After all, for a straight line, wouldn't tangentOnPath(0.999) be the same as tangentOnPath(1.0) (or, indeed any value x in the range of 0 to 1 for tangentOnPath(x)) ?  As you can see, the slight difference as suggested by @Dan Ebberts resolves the issue... I think it has more to do with how AE is computing the tangent at 1.0 rather than the angle of the line being nearly 309 or anything else for that matter.  After all, if it were due to 'certain angles the result will simply be 0', I would expect the arrowhead to randomly orient to 0, not randomly flipping 180 degress...  if it were due to the angle, I'd expect the same result regardless of x for a straight line, but by further testing, any value seems to work, except for 1.  Again, I'm sure there is a simple mathematical explaination, but why the tangent at 1 is causing this alludes me at the moment.

See this video for compaison...

Report

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

Copied

My bad, I meant 30. Fatty thumbs typing. *lol*

Mylenium

Report

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

Copied

Forgot: For the math it probably boils down to the vectors' dot product being zero at some point...

Mylenium

Report

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

Copied

LATEST

@Mylenium - Not sure I follow the 30 or dot product... but something is getting confused... you can see in this latest iteration that the dx and dy values are being 'flipped' randomly, e.g., resulting in the vector ending up in the opposite quadrant, and thus, the angle being roated 180deg.

https://youtu.be/4Vgf6Q5BbOc