How Do I Define A Slowly Tilting Plane On An LED Cube? (Warning, math ahead)
please watch video starting @ 0:43:
http://www.youtube.com/watch?v=03bkigwyox0.
i'm attempting recreate plane of leds tilting xy-plane xz-plane.
i have 4x4x4 cube.
here i've figured out far:
r = (0, 0, 0) + s(1, 0, 0) + t(0, y, z) y variable going 1->0 , z variable going 0->1
i can define 2 functions first increment z 0 1 , y 1 0, don't think elegant. thinking should done concurrently using 1 incrementor variable reduces y , increases z @ same time.
so here function (written , being testing in java):
now here problem: can restrict x values range 0 3 setting loop of s parameter go through 0 3. notice t variable. noticed when set 0 3, x , y values don't reach length of cube (i.e. y never equals 3). furthermore, because of rounding, plane 'doubles' up. say, @ y=2, leds @ z=0 , z=1 both on. not plane
i appreciate time reading , advice or code snippets or links.
http://www.youtube.com/watch?v=03bkigwyox0.
i'm attempting recreate plane of leds tilting xy-plane xz-plane.
i have 4x4x4 cube.
here i've figured out far:
r = (0, 0, 0) + s(1, 0, 0) + t(0, y, z) y variable going 1->0 , z variable going 0->1
i can define 2 functions first increment z 0 1 , y 1 0, don't think elegant. thinking should done concurrently using 1 incrementor variable reduces y , increases z @ same time.
so here function (written , being testing in java):
code: [select]
public static void main(string[] args){
double incrementor = 0.2; //0 -> 1;
for(int s = 0; s<4; s++){
for(int t=0; t<4; t++){
int x = s;
int y = (int)((t*(1-incrementor)) + 0.5); //1 -> 0
int z = (int)((t*incrementor)+ 0.5); //0 - 1
system.out.println("co-ordinates: (" + x + ", " + y + ", " + z + ")");
}
system.out.println();
}
}
now here problem: can restrict x values range 0 3 setting loop of s parameter go through 0 3. notice t variable. noticed when set 0 3, x , y values don't reach length of cube (i.e. y never equals 3). furthermore, because of rounding, plane 'doubles' up. say, @ y=2, leds @ z=0 , z=1 both on. not plane
i appreciate time reading , advice or code snippets or links.
maybe if deal in terms of "plane" series of parallel lines.
http://en.wikipedia.org/wiki/bresenham%27s_line_algorithm
but, still, compromise inevitable.
http://en.wikipedia.org/wiki/bresenham%27s_line_algorithm
but, still, compromise inevitable.
Arduino Forum > Using Arduino > LEDs and Multiplexing > How Do I Define A Slowly Tilting Plane On An LED Cube? (Warning, math ahead)
arduino
Comments
Post a Comment