Normals to a drawn line at runtime (incorrect math)?
Hello.
I have an equation which seemingly gives back Normals (line segments) to a line drawn with ActionScript and the mouse.
If I go from lesser mouseX position to greater mouseX position it seems to work fine.
line1Arr.rotation=45*Math.atan2(mouseYArr-mouseYArr[i-1], mouseXArr-mouseXArr[i-1]);
line1Arr is the instance of the line segment Normal that is being attached to the line and mouseXArr and mouseXArr[i-1] is the most recent point and the one before it.
The problem is that after having done a web search I think my math is not correct to calculate the normal. I have found a thread somewhere which mentions to use derivative of x and derivative of y to calculate the normals. Another member in the thread posted that one can also use sine and cosine to calculate this.
This is the problematic equation that I tried when going mouseX in the opposite direction
line1Arr.rotation=(-45)*Math.atan2(mouseXArr[i-1]-mouseXArr[i-0], mouseYArr[i-1]-mouseYArr[i-0]);
Any help with this math problem is greatly appreciated.
