Math Is Fun Forum

  Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °

You are not logged in.

#1 2005-09-23 13:38:20

sonyafterdark
Member
Registered: 2005-09-12
Posts: 28

Real tough one. Is real-time perfect sub pixel accuracy possible?

There is a square array of N by N (N is finite) squares (the squares themselves are 1 by 1 ).
Each square has a positive integer (let's call it colour) assigned .
This array is tiled to infinity in any direction upon some arbitrary plane.
The edges of the arrays are aligned.

An arbitrary triangle is drawn upon this plane. It may be however large or small, near to or far from the origin of the plane's system. I need to calculate the average colour of the triangle. This means that for each and every single square that comes under the arbitrary triangle, even partially, I will add to a sum (initially 0) the square's_colour_value/area_of_the_square_that_is_inside_the_triangle. After having done this for every single square that falls inside the triangle (even partially) I will have the average colour of the triangle; which leads me to my problem. Given the fact that the triangle may be however large, applying this complex method to any possible arbitrary triangle is not wise.

Is there any way in hell to scale down the triangle to within one of the finite tiles (the square arrays, first one for example) in such a way that I can be certain the cromatic average is not at all altered, in order to make it easier to calculate its cromatic average? Or would some other method work, other than scaling (it just popped into mind)? Please enlighten. 10x


Cheers, Vishy.


An intelligent man usually knows how to reach his goals. A wise man also knows what goals to reach...

Offline

#2 2005-09-23 17:10:15

ryos
Member
Registered: 2005-08-04
Posts: 394

Re: Real tough one. Is real-time perfect sub pixel accuracy possible?

Here's a simple suggestion that should help a little. I bet it could be developed further.

Precompute and store the average color of the entire array. Then, if you can figure out how many arrays are completely enclosed by the triangle, you've greatly reduced the amount of calculations you have to do.


El que pega primero pega dos veces.

Offline

#3 2005-09-24 02:11:51

sonyafterdark
Member
Registered: 2005-09-12
Posts: 28

Re: Real tough one. Is real-time perfect sub pixel accuracy possible?

10X Ryos.
Thought of this. But you can see how being able to somehow reduce the triangle to a single texture tile with no disturbance of the cromatic average is so much better.

Perfect actually. Especially considering how the triangle may be however large or far away from the centre of the plane's system. For an especially large one I might (the computer) have to work for minutes/hours.

And this triangle is only half a screen pixel projected on some polygon (the plane).

Can you imagine going through that immensly slow process for 2*1024*768*(at least)25 times a second?


Cheers, Vishy.

Last edited by sonyafterdark (2005-09-24 02:14:03)


An intelligent man usually knows how to reach his goals. A wise man also knows what goals to reach...

Offline

#4 2005-09-24 03:57:53

orange
Member
Registered: 2005-06-19
Posts: 73

Re: Real tough one. Is real-time perfect sub pixel accuracy possible?

hello again
wat happened about that hacker
i no her she said she only wanted to talk to me on the website but failed because she didnt have an email address

Offline

#5 2005-09-24 04:01:11

ryos
Member
Registered: 2005-08-04
Posts: 394

Re: Real tough one. Is real-time perfect sub pixel accuracy possible?

And this triangle is only half a screen pixel...

Oh! Why didn't you say so? If you know that your triangle is exactly half of a screen pixel, then you're talking about a very specific thing: a 45-45-90 triangle.

Two of these make a square. Now, let me ask a stupid question. Why are you even bothering with triangles, when squares are so much easier to work with given a square texture tile?


El que pega primero pega dos veces.

Offline

#6 2005-09-24 08:05:03

sonyafterdark
Member
Registered: 2005-09-12
Posts: 28

Re: Real tough one. Is real-time perfect sub pixel accuracy possible?

Hello again Ryos big_smile. No, no. You got it wrong.

The half pixel has almost nothing to do with the question at hand. I never said the arbitrary triangle is 45-45-90. How could an arbitrary triangle be a right-angle triangle?

The average colour of the arbitrary triangle, averaged again with a sister triangle that shares 2 tips with this one - for the other pixel half- , is the colour that the current screen pixel will have. There's no other link.

I am talking about perspective projection here. The average colours of the 2 sister triangles, averaged again between themselves, will determine the final colour of the current screen pixel to which they are projected on screen. In fact they lie somewhere on a polygon in 3D space. Thus they most certainly have no edges either perpendicular or parallel (between the 2 the triangles, I mean).

You can experiment this by simply sticking a square paper cutout CENTRED on a flashlight and pointing it at a wall at different angles, NOT JUST PERPENDICULARLY. Now try shutting the lights and turning the flashlight on big_smile.

The square cutout is the screen pixel. The lantirn is the eye and the wall is a polygon being seen by the eye. The (NOT SO square) quad. shadow on the wall is the 2 arbitrary sister triangles I'm talking about. Get it?

Last edited by sonyafterdark (2005-09-24 16:20:04)


An intelligent man usually knows how to reach his goals. A wise man also knows what goals to reach...

Offline

Board footer

Powered by FluxBB