Math Help: jit.gl.gridshape between two points XYZ

tohm's icon

Hi all,

I am drawing a blank... literally...

Given two XYZ points (say left sphere and right sphere), how can I draw a cube between them?

It seems I would need to get the center point (in XYZ) first...
Then be able to know the size/distance between the two points (I think I can get that thanks to MRdistance)

any and all help is welcome... I promise to share the kinect fun with this if this is possible...

thanks!
tohm
here is starting point I got to (without my disaster trials)

Max Patch
Copy patch and select New From Clipboard in Max.

`

Jesse's icon
Max Patch
Copy patch and select New From Clipboard in Max.

This should help a bit -- got rid of the mesh (you don't need it) and sent loadbang to the positions of the two spheres.

tohm's icon

thanks, it was a quick and dirty mock up....

any help on the math? I still can't find anything...

Jesse's icon

Add the respective position values of the spheres together and divide by 2?

( xSphere1 + xSphere2 ) / 2. = xCube
( ySphere1 + ySphere2 ) / 2. = yCube
( zSphere1 + zSphere2 ) / 2. = zCube

tohm's icon

I just had the same idea... and it works! Good things coming... my plan is to use the Kinect to move "boxes" of samples around a room... I already have the selection and effects built for 3d, now I just need to tweak...

Thanks for your help