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

Error: Invalid Numeric Result When Copying Slider Value

Community Beginner ,
Nov 12, 2023 Nov 12, 2023

Copy link to clipboard

Copied

I'm trying to modify a template I downloaded to make a pie chart. I would like to set a text layer to be in the center of a pie slice and I've tried writing the following code to accomplish that:

 

var C1 = thisComp.layer("Data control").effect("Chart value 1")("Slider");
var C2 = thisComp.layer("Data control").effect("Chart value 2")("Slider");
var C3 = thisComp.layer("Data control").effect("Chart value 3")("Slider");

var rotation_in_degrees =(C2+C3+(0.5*C1))*3.6;
var rotation_in_radians = rotation_in_degrees * Math.PI / 360;

var base_x_position = thisComp.layer("Chart 1").effect("Radial Wipe 1")("Wipe Center")[0];
var base_y_position = thisComp.layer("Chart 1").effect("Radial Wipe 1")("Wipe Center")[1];

var pie_chart_radius = thisComp.layer("Chart 1").content("Ellipse Path 1").size[0] / 2

[base_x_position + Math.acos(rotation_in_radians) * pie_chart_radius, base_y_position + Math.asin(rotation_in_radians) * pie_chart_radius, 0];

The problem is that this returning an error:

Error: invalid numeric result (divide by zero?)

 pointing at the the first line (var C1...)

 

This is raising problems for me, because from my perspective this value should simply be the number in the slider. How could it be an invalid numeric result? There is certainly no point at which this value could be divided by zero. 

TOPICS
Scripting

Views

149

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 ,
Nov 12, 2023 Nov 12, 2023

Copy link to clipboard

Copied

Just curious--why are you using Math.acos() and Math.asin()?

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 Beginner ,
Nov 12, 2023 Nov 12, 2023

Copy link to clipboard

Copied

LATEST

It was a mistake. I meant to use Math.sin() and Math.cos(). When I did this problem resolved itself

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