|
|
Dave Dunn wrote:
>
> There is probably somehting simple that I am missing (besides a brain)
> but I am at a loss. I am trying to be able to define a line between two
> vectors, as with a cylinder or cone definition (lets say <1,2,3> to
> <3,4,5>). Now, I want to use that line as an axis, as if it were, say Y,
> (<0,-2,0>,<0,2,0> for example), and offset a parallel line from this set
> of vectors. (As in <2,-2,0>,<2,2,0>) and create a while loop that
> generates a ring of lines around the original axis. The application I
> have in mind will not allow creating the figure at the Origin and
> rotating into place. Any help would be appreciated.
Below there's code for another way to do it.
(If I have understood your problem correctly.)
Note that the difference from my other
solution is that in this example the
original object is already in place out
by your "axis line".
Tor Olav
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 =
// Copyright 2001 by Tor Olav Kristensen
// mailto:tor### [at] hotmailcom
// http://hjem.sol.no/t-o-k
// http://www.crosswinds.net/~tok
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 =
#version 3.1;
#include "colors.inc"
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 =
#macro AxisRotateMatrix(vAxis, RotAngle)
#local v0 = vnormalize(vAxis);
#local Angle = radians(RotAngle);
#local Cos = cos(Angle);
#local vU = sin(Angle)*v0;
#local vW = (1 - Cos)*v0;
#local vA = v0.x*vW;
#local vB = v0.y*vW;
#local vC = v0.z*vW;
matrix <
vA.x + Cos, vA.y + vU.z, vA.z - vU.y,
vB.x - vU.z, vB.y + Cos, vB.z + vU.x,
vC.x + vU.y, vC.y - vU.x, vC.z + Cos,
0, 0, 0
>
#end // macro AxisRotateMatrix
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 =
// Remote "axis" start and end points
#declare pR1 = <1, 2, 3>;
#declare pR2 = <3, 4, 5>;
#declare vRemoteAxisDirection = pR2 - pR1;
#declare vRemoteAxisOrigin = (pR1 + pR2)/2;
// Show remote axis
cylinder { pR1, pR2, 0.2 pigment { color Cyan } }
// One single object in its final position
#declare Obj1 =
#cylinder {
pR1 + 2*y, pR2 + 2*y, 0.2
pigment { color Yellow }
}
// Un-translate it
#declare Obj2 =
object {
Obj1
translate -vRemoteAxisOrigin
}
// Rotate it around
#declare Obj3 =
union {
#declare Angle = 0;
#while (Angle < 360)
object {
Obj2
AxisRotateMatrix(vRemoteAxisDirection, Angle)
}
#declare Angle = Angle + 10;
#end // while
}
// And re-translate it all
object {
Obj3
translate vRemoteAxisOrigin
}
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 =
background { color Blue/2 }
camera {
location <-2, -1, 3>*2
look_at vRemoteAxisOrigin
}
light_source {
<1, 0, 3>*100
color White
shadowless
}
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 =
Post a reply to this message
|
|