Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

Re : Need some help with left to right/experiments with slitscan (Beginner's frustration)

$
0
0
I'll try to explain the math reason behind those mysterious calcs.

video = new Capture(this, 320, 240); makes your video screen w/ width = 320 & height = 240.

width/2 is the horizontal center of the video screen.

Now the logic behind -> drawPositionX = width - 1; :

Even though the video's width is 320, the 1st x position is not 1!
In most programming languages, the 1st position is 0!!!

So, a video w/ 320 width starts at 0 and ends at 319.

In the case above, drawPositionX = last farthest x location (or pixel) of the video. Its far right.
Also, you can consider the x pixel position as the column, and y as the row.

In short, the whole video screen is a 2D rectangle matrix,
which can be addressed by 2 scalar variables, the coordinate pair (x,y).

However, to represent that 2D matrix as a 1D array, you need the following formula:
index1D = row*width + column;  or  index1D = y*width + x;

Hope it's enough to get you started.
Although I think you should start w/ something easier. 

Viewing all articles
Browse latest Browse all 1768

Trending Articles