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.
Copy link to clipboard
Copied
Just curious--why are you using Math.acos() and Math.asin()?
Copy link to clipboard
Copied
It was a mistake. I meant to use Math.sin() and Math.cos(). When I did this problem resolved itself