POV-Ray : Newsgroups : povray.general : Vexing Vector Problem Server Time
20 Nov 2024 10:21:15 EST (-0500)
  Vexing Vector Problem (Message 1 to 8 of 8)  
From: Dave Dunn
Subject: Vexing Vector Problem
Date: 30 Aug 2001 12:34:19
Message: <3B8E6B33.D47BC901@aol.com>
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.


Post a reply to this message

From: Ben Chambers
Subject: Re: Vexing Vector Problem
Date: 30 Aug 2001 19:14:43
Message: <3b8ec8e3@news.povray.org>
"Dave Dunn" <poi### [at] aolcom> wrote in message
news:3B8E6B33.D47BC901@aol.com...
> 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.

What application are you using?  If it exports to POV files, then do this,
and then edit the file to rotate it into place by hand.

...Chambers


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Vexing Vector Problem
Date: 30 Aug 2001 19:26:54
Message: <3B8ECB7D.571A4BE2@hotmail.com>
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.

I hope that the code below provides a 
solution to your problem.

You may also have a look my answer to Ben
Chambers' "Rotations..." thread 7. Aug in
this group:

news://news.povray.org/3b6f392f%241%40news.povray.org


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 ReorientMatrix(vAxis1, vAxis2)

  #local v1 = vnormalize(vAxis1);
  #local v2 = vnormalize(vAxis2);
  #local vU = vcross(v1, v2);
  #local Dot = vdot(v1, v2);
  #local v0 = vnormalize(vU);
  #local vW = (1 - Dot)*v0;
  #local vA = v0.x*vW;
  #local vB = v0.y*vW;
  #local vC = v0.z*vW;

  matrix <
    vA.x + Dot,  vA.y + vU.z, vA.z - vU.y,
    vB.x - vU.z, vB.y + Dot,  vB.z + vU.x,
    vC.x + vU.y, vC.y - vU.x, vC.z + Dot,
    0,                0,                0
  >
  
#end // macro ReorientMatrix

// ===== 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 } }

// Central "y-axis" start and end points
#declare pC1 = -2*y;
#declare pC2 =  2*y;

#declare ObjectToBeRotated =
box {
  -<4, 6, 1>/10, <4, 6, 1>/10
  translate 2*x
}

#declare ObjectToBeTilted =
union {
  #declare Angle = 0;
  #while (Angle < 360)
    object { ObjectToBeRotated rotate Angle*y }
    #declare Angle = Angle + 10;
  #end // while
}

#declare ObjectToBeTranslated =
object {
  ObjectToBeTilted
  ReorientMatrix(y, vRemoteAxisDirection)
}

object {
  ObjectToBeTranslated
  translate vRemoteAxisOrigin
  pigment { color Yellow }
}

/*
// Or doing it all in one step
union {
  #declare Angle = 0;
  #while (Angle < 360)
    box {
      -<4, 6, 1>/10, <4, 6, 1>/10
      translate 2*x
      rotate Angle*y
    }
    #declare Angle = Angle + 10;
  #end // while
  ReorientMatrix(y, vRemoteAxisDirection)
  translate vRemoteAxisOrigin
  pigment { color Yellow }
}
*/

// ===== 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

From: Tor Olav Kristensen
Subject: Re: Vexing Vector Problem
Date: 30 Aug 2001 20:01:47
Message: <3B8ED3A9.7FBED4DF@hotmail.com>
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

From: dave
Subject: Re: Vexing Vector Problem
Date: 30 Aug 2001 20:47:20
Message: <3B8EDF05.FA9DD539@aol.com>
Ben Chambers wrote:

> What application are you using?  If it exports to POV files, then do this,
> and then edit the file to rotate it into place by hand.

This is a pure POV-Ray text question. Suppose you wanted to make a wireframe
cylinder. For an object centered at the Origin, this would be easy - simply
translate a thin cylinder x units away from the origin and rotate it in a
while loop. I am finding this more difficult to conceptualize using a line
between two arbitrary vectors as a virtual axis.


Post a reply to this message

From: dave
Subject: Re: Vexing Vector Problem
Date: 30 Aug 2001 20:51:04
Message: <3B8EDFE7.16C79355@aol.com>
> Below there's code for another way to do it.
> (If I have understood your problem correctly.)
> Tor Olav

Hmm, between the two of these methods I may have what I need. The object in
question is a wireframe cylinder created between two given points by
offsetting a thin cylinder and rotating it around the new axis. Thanks - I'll
give it a try...


Post a reply to this message

From: Dave Dunn
Subject: Re: Vexing Vector Problem
Date: 31 Aug 2001 10:48:37
Message: <3B8FA3ED.86C97AFC@aol.com>
Tor Olav Kristensen wrote:

> I hope that the code below provides a
> solution to your problem.

This was exactly what I was looking for. In fact I have several uses for it in
the funware project I am working on (POVGUI wireframe emulator - see
povray.binaries.utilities). I was hoping I could incorporate this macro into
my utility in a few places, in return for a grateful acknowledgement in the
docs...


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Vexing Vector Problem
Date: 31 Aug 2001 19:56:31
Message: <3B9023F3.2ED17F89@hotmail.com>
Dave Dunn wrote:
> 
> Tor Olav Kristensen wrote:
> 
> > I hope that the code below provides a
> > solution to your problem.
> 
> This was exactly what I was looking for. In fact I have several uses for it in
> the funware project I am working on (POVGUI wireframe emulator - see
> povray.binaries.utilities). I was hoping I could incorporate this macro into
> my utility in a few places, in return for a grateful acknowledgement in the
> docs...


See my email reply...

:)


Tor Olav


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.