Page 2 of 3

Re: RectOut

Posted: 20 Mar 2012, 15:52
by ricardocrl
I also noticed that the "width" and height" are not exactly right, considering my interpretation of the sizes. They are 1 pixel less then the actual size. If I as RectOut(0, 0, 4, 4) it will be a 5 x 5 square. Should that be corrected, or is there any reason for being like that?

Re: RectOut

Posted: 20 Mar 2012, 17:17
by mightor
Let's count the pixels; 0, 1, 2, 3, 4 <-- that's 5 pixels :)

- Xander

Re: RectOut

Posted: 20 Mar 2012, 18:37
by mattallen37
Yes, the bottom and left are sort of "free pixels".

I have been duplicating the FW drawing functions for use with BMP files. It has been a dilemma for me, trying to decide if I should do it like the FW, or logically. So far I have been doing it to match the FW.

@Xander, that's the point! it should be 4 pixels.

Re: RectOut

Posted: 20 Mar 2012, 19:02
by HaWe
actually not, Xander is right, it's just correct the way it currently is!
Imagine you have a fence with 5 fence posts in equal distance of 1 m:
| | | | |
between the first and last fence post is a distance (length) of 4m!

Imagine the fence posts are pixels, so if you have 5 pixels, then the distance (length) between the 1st and the 5th is 4 !
1 pixel does not define a line or a square but a point (elongation = 0 !) - the same way as 1 fence post does not define a line or a square but just a point (more or less),
4 pixels ( 2 in each dimension, wide and high) define the smallest thinkable square with a lenght =1 of each side (2 pixels each, vertices are counted twice!),

and if your square has a length and a heighth of 41 , then the number of pixels (or fence posts) on each side is...
Image
:!:

Amazing, isn't it ?
:D

Re: RectOut

Posted: 20 Mar 2012, 20:03
by mightor
Ah yes, they're not both absolute coordinates, my bad.

- Xander

Re: RectOut

Posted: 20 Mar 2012, 20:22
by mattallen37
Helmut, I understand your logic, but I don't agree that it should be like that.

Anyhow, it's super easy to make wrap-up functions for anyone who wants it the other way. For compatibility reasons, I am 100% in favor of keeping it the way it is.

Re: RectOut

Posted: 20 Mar 2012, 20:42
by HaWe
that's not my logic, that's simply logical!

defining a rectangle, you have to define 1 start point (corner) and then you define the additional length and the height.
if you have 1 pixel as a start point (starting corner) and you add +1 for the length and +1 for the height you will get 1 more pixel at the right side of it and 1 more pixel directly above plus 1 pixel diagonally opposite = 4 pixels over all.

1 pixel corresponds to a point which has no area,
if you add +0 for the height (just 1 pixel "high") and +1 for the length (2 pixels side by side) you get a 2-pixel line (length=1), not a 1x2 rectangle.

Other way round:
the length between 2 cartesic coordinates is = sqrt (dx² + dy²)
end= (10,0)
start= (9,0)
length= sqrt ((10-9)² + 0²) = sqrt(1) = 1
so 2 pixels side by side (e.g., on 1 side of a rectangle) have a distance (length) of 1.

Re: RectOut

Posted: 20 Mar 2012, 20:58
by mattallen37
doc-helmut wrote:...1 pixel corresponds to a point which has no area...
Right, I totally get it, but that's just not the way it appears.

Re: RectOut

Posted: 20 Mar 2012, 21:04
by HaWe
well, actually the reality never is ike it appears to be ;)

Imagine the pixels to be coordinates, not areas, then they will appear more to be what they actually are... :)

test it:
in your model, if you have 2 pixels above each other and also side by side: what will be your calculated diagonal length of that
::
square (distance from lower left to upper right)?

Re: RectOut

Posted: 20 Mar 2012, 21:14
by mattallen37
I totally and completely understand what you mean, and the logic you are using. I just personally see it the other way just as much.