A small problem for any geometry/maths-heads out there. I am exporting models from Processing into 3D programs, and find that 1 dimensional lines with variable stroke widths that look pretty effective in processing lose their width detail in the export process. So I'm now trying to plot thin 3D boxes in place of lines, meaning a translation operation to the line's mid-point, and a rotation operation of the frame of reference so that the box's Z dimension is adjacent to the line's vector. I've made a simple example script to illustrate: https://gist.github.com/2770618
Annoyingly the rotation operation does not quite work as intended - the box is aligned approximately but not precisely with the line it is trying to replicate. But I've tried all other combinations I can think of - e.g. making all numbers floats - with no luck, and can't work out where I'm going wrong.
I found an alternative route. Here is an example using Toxiclibs that turns a 3D line made from two vector points into a correctly aligned, translated and rotated box. The camera rotates automatically. The mouse moves one point. Press the mouse to randomly set the other point.
amnon.owed for these helpful suggestions. I've now managed to resolve the problem, which I think was due to the way that Processing's trigonometry functions work - atan() does not appear to function properly in negative quadrants. I changed to atan2() function and adjusted the code accordingly and it works perfectly now. You can see the result here: https://vimeo.com/42840794
However I have saved your code as it will certainly come in handy at some point when I start building shapes, so thanks for this!