etienne_marais
Honorary Master
There is a term for it, read it recently but forgot what it is.
Basically I have written a small gfx program that rotates a cube around the z-axis.
private Point RotZ(double degree, Point p)
{
Point r = new Point(p.X, p.Y);
r.X = (int)(p.X*Math.Cos(degree) - p.Y*Math.Sin(degree));
r.Y = (int)(p.X*Math.Sin(degree) + p.Y*Math.Cos(degree));
return r;
}
In the main loop: p1 = RotZ(Math.PI / 20, p1); // (and same for other points)
After many iterations of the loop, p1 loses accuracy/precision/whatever so the effect is that the cube becomes smaller and smaller with more iterations of the loop as the 8 points lose 'accuracy'.
I suppose one way to prevent this is to keep track of the angle you are rotating and have that increase instead of reassigning the points each iteration (so the points' values stay the same and you simply rotate a set of new points relative to the original).
I would like to know however how this is typically handled in real applications.
Basically I have written a small gfx program that rotates a cube around the z-axis.
private Point RotZ(double degree, Point p)
{
Point r = new Point(p.X, p.Y);
r.X = (int)(p.X*Math.Cos(degree) - p.Y*Math.Sin(degree));
r.Y = (int)(p.X*Math.Sin(degree) + p.Y*Math.Cos(degree));
return r;
}
In the main loop: p1 = RotZ(Math.PI / 20, p1); // (and same for other points)
After many iterations of the loop, p1 loses accuracy/precision/whatever so the effect is that the cube becomes smaller and smaller with more iterations of the loop as the 8 points lose 'accuracy'.
I suppose one way to prevent this is to keep track of the angle you are rotating and have that increase instead of reassigning the points each iteration (so the points' values stay the same and you simply rotate a set of new points relative to the original).
I would like to know however how this is typically handled in real applications.
Last edited: