I'm currently tackling the task of extracting data from a file generated by a software program that has the ability to add a shadow effect to text. The user interface allows you to specify an angle, length, and radius for this shadow.
https://i.stack.imgur.com/INbLn.png
When these values are set as shown in the provided screenshot, the data is stored within an XML node in the following format:
10|{1.41421356237309, -1.4142135623731}
The structure is as follows:
radius|{offsetX, offsetY}
My goal is to reverse-engineer these values back into the original angle and length, so I can include them in my parsing process. While scouring the internet, I've come across solutions for calculating offsets based on angle and length, but not the other way around.
let length = 2;
let angle = 135;
let shadowX = Math.sin(angle * (Math.PI / 180)) * length;
let shadowY = Math.cos(angle * (Math.PI / 180)) * length;
console.log(shadowX, shadowY); //1.4142135623730951 -1.414213562373095
This is where I regret not paying closer attention in my algebra classes. I am uncertain about the next steps to take in order to derive the desired values. My objective is to input the X/Y offset values and get the corresponding angle and length as output.