# GMLscripts.com

Discuss and collaborate on GML scripts

You are not logged in.

## #1 2009-06-22 07:57:18

icuurd12b42
Member
Registered: 2008-12-11
Posts: 303

### image_angle is drawn as though it is 0 when between 0 and 1;

to replicate and visualize

1) Create a large square, 256x256, set origins centered, set tranparent false

2) create an object, set it to use the sprite, add image_angle+=.01 in the step event

3) Add to a room, set the fps low to see it

http://cid-fba0b7e57cc98d0a.skydrive.li … 7C_bug.gmk

draw_sprite_ext is also affected

It's not too noticable in small sprites, but for large ones that rotate slowly, it is clearly visible.

Offline

## #2 2009-06-22 14:32:26

flexaplex
Member
Registered: 2008-12-11
Posts: 72

### Re: image_angle is drawn as though it is 0 when between 0 and 1;

Hmm.

I've altered the example file so you can test more clearly:
http://www.box.net/shared/yue1p41sy0

It appears the image with 0-360 is not transformed until the image_angle gets to 0.58. However the same thing does actually occur with 360-720 except now it is at the value 360.24 instead. Rotating right you can also see the images are not transformed until it gets to 359.76 or 719.76, so the same thing occurs except now to a 0.24 degree for both.

I've tested images at 90,180,270 also. Those all behave the same with a margin of 0.24 either side before the image is transformed.

So clearly Mark has intentionally put in a accuracy condition which only transforms the images when the rotation increment is beyond 0.24, this is obviously so images then aren't unwantingly rotated due to number imprecision at these angles. The reason the accuracy to the left of 0 is set to 0.58 instead of 0.24 is either because it is a mistake or I think more likely because the number imprecision is more important/common at that point.

Last edited by flexaplex (2009-06-22 14:40:59)

Offline

## #3 2009-06-23 02:45:58

icuurd12b42
Member
Registered: 2008-12-11
Posts: 303

### Re: image_angle is drawn as though it is 0 when between 0 and 1;

so my +360 is not a fix at all. I guess you need to use transform_add_rotation_z then...

Offline

## #4 2009-06-30 17:24:22

flexaplex
Member
Registered: 2008-12-11
Posts: 72

### Re: image_angle is drawn as though it is 0 when between 0 and 1;

Actually I just tested d3d_transform_add_rotation_z and it has the same accuracy issue except it's smaller at 0.11 instead of 0.24 before the image is drawn transformed. I am not a big fan of Mark adding this feature in to rotations, I can see why he has done it but now it is very annoying to workaround if you need more precision. Really these accuracy measures are something the user should add themselves if wanted.

Now if you want to properly work around this I think you are going to have to call 2 rotations and check the angle before hand.

Edit: I thought this might work:

accuracy = 0.59;
if (abs(angle_difference(image_angle,round(image_angle/90)*90)) < accuracy)
{
d3d_transform_set_identity();
draw_sprite_ext(sprite_index,image_index,0,0,image_xscale,image_yscale,image_angle-45,c_white,image_alpha);
d3d_transform_set_identity();
}
else
{
draw_sprite_ext(sprite_index,image_index,x,y,image_xscale,image_yscale,image_angle,c_white,image_alpha);
}

But it still has the same issue.

So I cannot think of a way around this yet.

Last edited by flexaplex (2009-06-30 18:01:31)

Offline

## #5 2009-06-30 23:52:09

icuurd12b42
Member
Registered: 2008-12-11
Posts: 303

### Re: image_angle is drawn as though it is 0 when between 0 and 1;

I cant see why he added it either... The chances of hitting problem due to precision is rather small since most objects are drawn angle 0 or other rounded angles by the programmer anyway and any precision erro should, in theory no wven be visible. This really screws people trying to make stuff rotate real smoothly. This can be a huge problem for big space ships

so you say frac 0.58 for 0 to 1 then .24 for 360 to 361 and 720-721? was is it for even bigger angles or negative ones?

Offline

## #6 2009-07-01 06:56:22

flexaplex
Member
Registered: 2008-12-11
Posts: 72

### Re: image_angle is drawn as though it is 0 when between 0 and 1;

Using image_angle it is 0.24 to the left and right of every angle at increments of 90 except to the right of 0 where it is 0.58. Ie:

...  (-270.24 to -269.76), (-180.24 to -179.76), (-90.24 to -89.76), (-0.58 to 0.58), (89.76 - 90.24), (179.76 to 180.24), (269.76 to 270.24), (359.76 to 360.24), (449.76 to 450.24) ...

Using d3d_transform_add_rotation_z it does exactly the same thing except at a lesser degree of 0.11 instead of 0.24 and the anomaly at 0.58 doesn't exist it is just 0.11.

Last edited by flexaplex (2010-05-20 08:16:06)

Offline

## #7 2010-05-20 08:19:31

flexaplex
Member
Registered: 2008-12-11
Posts: 72

### Re: image_angle is drawn as though it is 0 when between 0 and 1;

Just to note that the 0.58 precision was fixed in GM8. The precision is now set to 0.24 around 0 also. I did just find out something else about image_angle though.. that it's drawn value seems to be rounded to 2 decimal places.

Last edited by flexaplex (2010-05-21 07:12:38)

Offline

## #8 2010-05-20 13:00:56

icuurd12b42
Member
Registered: 2008-12-11
Posts: 303

### Re: image_angle is drawn as though it is 0 when between 0 and 1;

flexaplex wrote:

Just to note that the 0.58 precision was fixed in GM8. The precision is now set to 0.24 around 0 also. I did just find out something else about image_angle though.. that it's value seems to be rounded to 2 decimal places..

So this implies image_angle += .001 would not work correct? But it does work in the test program...

So you must imply that the draw, or the visible increment is .01

Offline

## #9 2010-05-21 07:11:59

flexaplex
Member
Registered: 2008-12-11
Posts: 72

### Re: image_angle is drawn as though it is 0 when between 0 and 1;

icuurd12b42 wrote:

So you must imply that the draw, or the visible increment is .01

Yer sorry, that's what I meant.

Offline