www.jpct.net
jPCT  a 3d engine for Java => Support => Topic started by: dunkedbiscuit on January 27, 2012, 09:59:50 pm

Hi
I have two SimpleVectors, with which I create a direction vector. I will use this direction vector draw a line between the two SimpleVectors. I want to draw multiple lines that are parallel to this line, and with a bit of distance between them. Does anyone know how I could do this?
Many thanks

Lines just like...lines? In that case, maybe this helps: http://www.jpct.net/forum2/index.php/topic,1679.msg12555.html (http://www.jpct.net/forum2/index.php/topic,1679.msg12555.html)

Not really, what would be ideal would be to align a place with the direction vector, so that both ends are touching the end points of the line, and the z coordinates of the plane's verts at each end of the line to be identical, so it would be level. Sort of like building a ramp.

I think i got what you want...but i don't get the actual problem...?

Basically, I have a line already (as in the direction vector), and I want to create a copy of it, but translated an arbitrary distance from the original line, making it parallel with the original line. My vector math is horrible!

And you have a direction vector? Then just create clones of your orginal line and translate them by a multiple of your direction vector.

OK. Do you have any source code?

Not sure what i should post here...it's just something like
Object3D copy=new Object3D(master, true);
SimpleVector trs=new SimpleVector(direction);
trs.scalarMul(<whatever>);
copy.translate(trs);

Well, here's what I'm doing so far. I calculate a cross product vector between the two points on the line, and then I get the direction vector between the first point (this) and the cross product vector.
SimpleVector crossProduct = new SimpleVector( this.calcCross(otherNode) );
SimpleVector directionVector = new SimpleVector(
crossProduct.x  this.x,
crossProduct.y  this.y,
crossProduct.z  this.z );
I then draw a line between the cross product and the first point using Java2D and Interact2D. I also draw a line between the first point (this) and the last point of the line (otherNode). I then draw the cross product point at the end of the line betwen the cross product and the first point, and the first point at the other end. Next, I multiply the directionVector by 0.5 using scalarMul and draw its position as a point.
The problem is that this new directionVector does not rest on the line between crossProduct and the first point (this). I think that the scalarMul somehow skews it and I don't know how to fix it. This is really the crux of my problem.

Not to worry. The positions didn't work as expected because there we some zeros in the SimpleVectors I was calculating the direction vector with. A satisfactory outcome.