For each coordinate of the old image, the new coordinate can be found by using this formula:

OldImageX = NewImageX * cos(theta) - NewImageY * sin(theta)

OldImageY = NewImageX * sin(theta) + NewImageY * cos(theta)

(theta is angle in radians)

NewImageX and Y is the new, rotated image coordinates. OldImage is the coordinates to extract the pixel from the old image.

Example:

for i := 0 to NewSprite.Width - 1 do

for j := 0 to NewSprite.Height - 1 do begin

nx := (round(x*Cos(A)-y*Sin(A)));

ny := (round(x*Sin(A)+y*Cos(A)));

Sprite[i,j] := OldSprite[nx,ny];

end;

Note that A must be in radians. To convert from degrees to radians, you multiply by (pi/180).

Example: the sin of 45 degrees would be

sin(45*pi/180);

In your question, you said you wanted to find X if sin(x) = a. This would entail finding the inverse sin of a. I don't know why you would want to find this. But if you really need to know how to calculate an inverse sin in pascal:

function arcsin(x:real):real;

begin

arcsin := arctan(x/sqrt(1-sqr(x)));

end;

If you send the function a real value (from -1 to 1 inclusive, the range of the sin function), it will return an angle in radians.

This function will have no practical purpose in rotating something, so consider looking over calculations again.

But your question also says you have the angle. If you want to find the sin of the angle (which is probably what you want to do) you simply use the sin function:

X := sin(a); {a is in radians; see note above}

Your formula, sin(x) = angle, would NEVER be used in any practical calculation anywhere.

Try using the formulas I gave you above (OldImageX..etc.) and if that is not what you want let me know.

OldImageX = NewImageX * cos(theta) - NewImageY * sin(theta)

OldImageY = NewImageX * sin(theta) + NewImageY * cos(theta)

(theta is angle in radians)

NewImageX and Y is the new, rotated image coordinates. OldImage is the coordinates to extract the pixel from the old image.

Example:

for i := 0 to NewSprite.Width - 1 do

for j := 0 to NewSprite.Height - 1 do begin

nx := (round(x*Cos(A)-y*Sin(A)))

ny := (round(x*Sin(A)+y*Cos(A)))

Sprite[i,j] := OldSprite[nx,ny];

end;

Note that A must be in radians. To convert from degrees to radians, you multiply by (pi/180).

Example: the sin of 45 degrees would be

sin(45*pi/180);

In your question, you said you wanted to find X if sin(x) = a. This would entail finding the inverse sin of a. I don't know why you would want to find this. But if you really need to know how to calculate an inverse sin in pascal:

function arcsin(x:real):real;

begin

arcsin := arctan(x/sqrt(1-sqr(x)));

end;

If you send the function a real value (from -1 to 1 inclusive, the range of the sin function), it will return an angle in radians.

This function will have no practical purpose in rotating something, so consider looking over calculations again.

But your question also says you have the angle. If you want to find the sin of the angle (which is probably what you want to do) you simply use the sin function:

X := sin(a); {a is in radians; see note above}

Your formula, sin(x) = angle, would NEVER be used in any practical calculation anywhere.

Try using the formulas I gave you above (OldImageX..etc.) and if that is not what you want let me know.