I have been working on a c# vector class in order to practice my skills and teach myself and I came across a rather infuriating issue.
public void Rotate (double rotation)
{
double xT;
xT = x * Math.Cos (rotation * (Math.PI / 180)) - y * Math.Sin (rotation * (Math.PI / 180));
y = x * Math.Sin (rotation * (Math.PI / 180)) + y * Math.Cos (rotation * (Math.PI / 180));
x = xT; /*Figure out a better way to this*/
}
This code is sloppy I know, but the issue comes from when I try a simple rotation of (1,0) 180 degrees around, instead of the expected (-1,0) that I should get, it instead returns (-1, -6.2343e-12) or something to that extent.
I understand that this is a issue with a lack of exactness in doubles, but I want to know if there is a way to have it still return a 0 instead of a number to the -12th.
Is there any way to do this?