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

Expressions. Finding an error

Engaged ,
Oct 18, 2022 Oct 18, 2022

Copy link to clipboard

Copied

Hi all.

Link to project file

https://drive.google.com/file/d/1FEXf970NN_MgKxgOmItByiXgOWM85kzk/view?usp=sharing  

 

Changing the Scale property, depending on the position of the camera.

 

When the camera approaches the composition being filmed,
the scale of the composition should change downwards.
And ultimately in the "Camera 1" window, the view should remain unchanged.

Property -- comp("Test").layer("CompA").transform.scale.expression =
--------------------------------------------------------------------
    CSP = [0,0,-2000]; //camera start position
    CP = thisComp.layer("CamControl").transform.position; //camera position
    Zero = [0,0,0];

    iniLenth = length(sub(CSP , Zero));

    carentLenth = length(sub(Zero, CP));

    carentScale = (carentLenth/iniLenth)*100;

    [carentScale, carentScale, carentScale];
---------------------------------------------------------------------

In my opinion, the expression is written correctly, but

When the camera approaches the composition being filmed,
its scale changes, and the initial value of the SCALE property is 104.1 ????

TOPICS
Expressions

Views

119

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

Community Expert , Oct 18, 2022 Oct 18, 2022

I think the problem is that you're calculating the distance from the camera to the target comp and the target comp is off the camera's z axis. Instead, you should calculate the distance to the camera's focal plane where it includes the target layer, kind of like explained here:

http://www.motionscript.com/design-guide/auto-focus.html

I'd do it like this:

c = thisComp.layer("Camera 1");
// get current distance
v1 = toWorld(anchorPoint) - c.toWorld([0,0,0]);
v2 = c.toWorldVec([0,0,1]);
d = dot(v1,
...

Votes

Translate

Translate
Community Expert ,
Oct 18, 2022 Oct 18, 2022

Copy link to clipboard

Copied

I think the problem is that you're calculating the distance from the camera to the target comp and the target comp is off the camera's z axis. Instead, you should calculate the distance to the camera's focal plane where it includes the target layer, kind of like explained here:

http://www.motionscript.com/design-guide/auto-focus.html

I'd do it like this:

c = thisComp.layer("Camera 1");
// get current distance
v1 = toWorld(anchorPoint) - c.toWorld([0,0,0]);
v2 = c.toWorldVec([0,0,1]);
d = dot(v1,v2);
// get initial distance
v1_0 = toWorld(anchorPoint,0) - c.toWorld([0,0,0],0);
v2_0 = c.toWorldVec([0,0,1],0);
d_0 = dot(v1_0,v2_0);

s = (d/d_0)*100;
[s,s,s]

 

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
Engaged ,
Oct 18, 2022 Oct 18, 2022

Copy link to clipboard

Copied

LATEST

I have read the article. Yes, not everything is as simple as it seems. Thank you.

 

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