POV-Ray : Newsgroups : povray.general : Req: a #macro to reorient a vector Server Time
15 Nov 2024 13:21:00 EST (-0500)
  Req: a #macro to reorient a vector (Message 1 to 10 of 12)  
Goto Latest 10 Messages Next 2 Messages >>>
From: Peter Popov
Subject: Req: a #macro to reorient a vector
Date: 26 Jan 1999 23:30:58
Message: <36ae955f.29754025@news.povray.org>
I know you can reorient  an object to lie along a specified axis, but
I need to do the same with a vector. I have finished a twister include
for creating really weird (and cool!) twisted objects, but I want to
have a way to customize all the main functions (axis, radius, etc.),
i.e. have a coil generated along a circle or any other #macro defined
curve. Thanks for any help.

Peter


Post a reply to this message

From: Ken
Subject: Re: Req: a #macro to reorient a vector
Date: 27 Jan 1999 00:40:33
Message: <36AEA6BE.99FD506F@pacbell.net>
Peter Popov wrote:
> 
> I know you can reorient  an object to lie along a specified axis, but
> I need to do the same with a vector. I have finished a twister include
> for creating really weird (and cool!) twisted objects, but I want to
> have a way to customize all the main functions (axis, radius, etc.),
> i.e. have a coil generated along a circle or any other #macro defined
> curve. Thanks for any help.
> 
> Peter

Take a look at the macros at the Macro Station. You may find
what you need there.

http://twysted.net/

-- 
Ken Tyler

tyl### [at] pacbellnet


Post a reply to this message

From: Stephen Lavedas
Subject: Re: Req: a #macro to reorient a vector
Date: 27 Jan 1999 01:12:23
Message: <36AEAE47.F589D818@virginia.edu>
Well, you are better at this math than I am...you can of course rotate
vectors around axis, (vaxis_rotate) also, if you know the length of a
vector (I believe there is a function for that) you could of course just
create a vector <L,0,0> where L is the length of the vector, and x is
the axis you want it along.  Otherwise, finding the angle between the
axis isn't too hard, just some simple trig involving the length of the
vector, and the component you want to lose (ie if you want it along the
xy plane, it would be asin(z/L)... I don't know exactly what you want,
but perhaps that helps?

Steve


Peter Popov wrote:
> 
> I know you can reorient  an object to lie along a specified axis, but
> I need to do the same with a vector. I have finished a twister include
> for creating really weird (and cool!) twisted objects, but I want to
> have a way to customize all the main functions (axis, radius, etc.),
> i.e. have a coil generated along a circle or any other #macro defined
> curve. Thanks for any help.
> 
> Peter


Post a reply to this message

From: Peter Popov
Subject: Re: Req: a #macro to reorient a vector
Date: 27 Jan 1999 21:42:15
Message: <36b023ea.8100515@news.povray.org>
I am following myself here, as it seems I didn't state the problem
clearly enough. What I need is a #macro that works like the "Reorient"
#macro on #Macroscope, but is used with a vector. Why? 

Suppose you have a point A rotating  around the origin in the xz
plane.Move the poiont up at the same time and you get a helix. What I
want to do is a helix whose axis is defined by a function (a #macro,
actually), so that it can be coiled aroind a circle, sine wave, or
whatever else. How?

Now let t be the variable of which the coordinates of A (x and z only,
y=0) and the helix axis are functions A(t) and H(t) respectively. What
I want to do is calculate A(t) and then reorient it along dH(t)/dt and
then rtanslate it to H(t). I need the coordinates of the object, not
the actual object transformed by a matrix, because I need them for
texture uv mapping (that's the whole point).

With these things cleared out (I hope), can anyone help me? I will
really appreciate it.

Peter


Post a reply to this message

From: Stephen Lavedas
Subject: Re: Req: a #macro to reorient a vector
Date: 27 Jan 1999 22:13:45
Message: <36AFD5EB.879C3464@virginia.edu>
Are you defining the Helix by rotation or by sin and cos?  I have
written a function to wrap a Helix around a Helix using sins and cos, so
I think I should be able to do what you are asking if I understand
correctly.  Now, do you want the #macro to define one point/vector, or a
whole series of points/vectors... Actually, that is an important
destinction... you want the VECTOR right?  The vector from the axis of
the object being wrapped around... hmmm... um... let me look at the
Reorient #macro....I can give you the points...then the vector would be
the difference of the two points right?  That is what you want?  That
value?

Steve

sorry if I am being dense...

Peter Popov wrote:
> 
> I am following myself here, as it seems I didn't state the problem
> clearly enough. What I need is a #macro that works like the "Reorient"
> #macro on #Macroscope, but is used with a vector. Why?
> 
> Suppose you have a point A rotating  around the origin in the xz
> plane.Move the poiont up at the same time and you get a helix. What I
> want to do is a helix whose axis is defined by a function (a #macro,
> actually), so that it can be coiled aroind a circle, sine wave, or
> whatever else. How?
> 
> Now let t be the variable of which the coordinates of A (x and z only,
> y=0) and the helix axis are functions A(t) and H(t) respectively. What
> I want to do is calculate A(t) and then reorient it along dH(t)/dt and
> then rtanslate it to H(t). I need the coordinates of the object, not
> the actual object transformed by a matrix, because I need them for
> texture uv mapping (that's the whole point).
> 
> With these things cleared out (I hope), can anyone help me? I will
> really appreciate it.
> 
> Peter


Post a reply to this message

From: Peter Popov
Subject: Re: Req: a #macro to reorient a vector
Date: 27 Jan 1999 22:28:39
Message: <36b1d855.28283057@news.povray.org>
On Wed, 27 Jan 1999 22:13:47 -0500, Stephen Lavedas
<swl### [at] virginiaedu> wrote:

>Are you defining the Helix by rotation or by sin and cos?  I have

By sin and cos, but the result is still a vector :)

>written a function to wrap a Helix around a Helix using sins and cos, so
>I think I should be able to do what you are asking if I understand
>correctly.  Now, do you want the #macro to define one point/vector, or a
>whole series of points/vectors... Actually, that is an important
>destinction... you want the VECTOR right?  The vector from the axis of

Yes, I need the *vector*. Not the one from the axis (which, as I
mentioned, is dH(t)/dt or, as you say, point 2 - point 1), but that of
the actual helix coiled around the axis. 

>the object being wrapped around... hmmm... um... let me look at the
>Reorient #macro....I can give you the points...then the vector would be
>the difference of the two points right?  That is what you want?  That
>value?
>
>Steve
>
>sorry if I am being dense...

Sorry for being denser :)

Peter


Post a reply to this message

From: Jerry Anning
Subject: Re: Req: a #macro to reorient a vector
Date: 28 Jan 1999 03:06:34
Message: <36B01A89.2223A220@dhol.com>
Peter Popov wrote:
> 
> I am following myself here, as it seems I didn't state the problem
> clearly enough. What I need is a #macro that works like the "Reorient"
> #macro on #Macroscope, but is used with a vector. Why?
> 
> Suppose you have a point A rotating  around the origin in the xz
> plane.Move the poiont up at the same time and you get a helix. What I
> want to do is a helix whose axis is defined by a function (a #macro,
> actually), so that it can be coiled aroind a circle, sine wave, or
> whatever else. How?
> 
> Now let t be the variable of which the coordinates of A (x and z only,
> y=0) and the helix axis are functions A(t) and H(t) respectively. What
> I want to do is calculate A(t) and then reorient it along dH(t)/dt and
> then rtanslate it to H(t). I need the coordinates of the object, not
> the actual object transformed by a matrix, because I need them for
> texture uv mapping (that's the whole point).
> 
> With these things cleared out (I hope), can anyone help me? I will
> really appreciate it.

If I understand you correctly, I did something similar a while ago as part of a
collaboration with Jamis Buck.  The idea was to create a telephone cord by
wrapping a helix around (and along) a spline.  Instead of a spline and helix you
could use your "H(T)" and "A(T)" functions.  Quickly and untestedly translating
the guts of my work (based on VanSickle's 3.02 version Matrix Page), here is a
macro that should do what you want.  In essence, it is a specialized version of
the reorient macro in which the matrix transforms are done explicitly, "up" is
hardwired to the Y axis, it calls global A(T) and H(T) functions, and it adds
the eventual vector-pointing-to-the-position to the point along H to get the
(transformed) point along A if my quick late night UNTESTED translation is
accurate.  In any case, the basis is sound and you can probably fix any errors. 
Macro follows after my signature.

Jerry Anning
cle### [at] dholcom

// Begin POV code

#macro Vreorient(T)
  #local Ht = H(T);
  #local Vx2 = ((T = 0) ? 0 : vnormalize (H(Oldt) - Ht);
  #declare Oldt = T;
  #local Vx1 = <0, 1, 0>;
  #local Vy = vnormalize(vcross(Vx2, Vx1);
  #local Vz1 = vnormalize(vcross(Vy, Vx1);
  #local Vz2 = vnormalize(vcross(Vy, Vx2);
  #local At = A(T);
  #local A1 = vdot(At, Vx1);
  #local A2 = vdot(At, Vy);
  #local A3 = vdot(At, Vz1);
  #local Apos = <vdot(At, Vx1), vdot(At, Vy), vdot(At, Vz1)>;
  #local B1 = <Vx2.x, Vy.x, Vz2.x>;
  #local B2 = <Vx2.y, Vy.y, Vz2.y>;
  #local B3 = <Vx2.z, Vy.z, Vz2.z>;
  <vdot(Apos, B1), vdot(Apos, B2), vdot(Apos, B3)> + Ht
#end

// End POV code


Post a reply to this message

From: Peter Popov
Subject: Re: Req: a #macro to reorient a vector
Date: 28 Jan 1999 22:49:29
Message: <36b0b7c7.137583@news.povray.org>
On Thu, 28 Jan 1999 03:06:34 -0500, Jerry Anning <cle### [at] dholcom>
wrote:

>If I understand you correctly, I did something similar a while ago as part of a
>collaboration with Jamis Buck.  The idea was to create a telephone cord by
>wrapping a helix around (and along) a spline.  Instead of a spline and helix you
>could use your "H(T)" and "A(T)" functions.  Quickly and untestedly translating
>the guts of my work (based on VanSickle's 3.02 version Matrix Page), here is a
>macro that should do what you want.  In essence, it is a specialized version of
>the reorient macro in which the matrix transforms are done explicitly, "up" is
>hardwired to the Y axis, it calls global A(T) and H(T) functions, and it adds
>the eventual vector-pointing-to-the-position to the point along H to get the
>(transformed) point along A if my quick late night UNTESTED translation is
>accurate.  In any case, the basis is sound and you can probably fix any errors. 
>Macro follows after my signature.
>
>Jerry Anning
>cle### [at] dholcom
>
<code>

That's exactly what I need, thank you. There is a small problem,
though - it doesn't work. No, I don't mean your math is wrong, I am
saying that when I modified it to suit my needs (and generally having
no idea what I was doing), it ceased to operate. On the other hand, if
I totally rewrite the include file *it* will stop working. So, if you
can please tweak it so that it takes as parameters not T, but three
vectors - axis1, axis2 and point, axis1 and axis2 being H(T) and
H(T+dT), and point being A(T), you will do me a great favor.

Thanks for your help.

Peter


Post a reply to this message

From: Jerry Anning
Subject: Re: Req: a #macro to reorient a vector
Date: 28 Jan 1999 23:49:04
Message: <36B13DBB.1993787F@dhol.com>
Peter Popov wrote:
> So, if you
> can please tweak it so that it takes as parameters not T, but three
> vectors - axis1, axis2 and point, axis1 and axis2 being H(T) and
> H(T+dT), and point being A(T), you will do me a great favor.

Try the following.

Jerry Anning
cle### [at] dholcom

//Begin POV code

#macro Vreorient2(axis1, axis2, point)
  #local Vx2 = vnormalize (axis2 - axis1);
  #local Vx1 = <0, 1, 0>;
  #local Vy = vnormalize(vcross(Vx2, Vx1);
  #local Vz1 = vnormalize(vcross(Vy, Vx1);
  #local Vz2 = vnormalize(vcross(Vy, Vx2);
  #local A1 = vdot(point, Vx1);
  #local A2 = vdot(point, Vy);
  #local A3 = vdot(point, Vz1);
  #local Apos = <vdot(point, Vx1), vdot(point, Vy), vdot(point, Vz1)>;
  #local B1 = <Vx2.x, Vy.x, Vz2.x>;
  #local B2 = <Vx2.y, Vy.y, Vz2.y>;
  #local B3 = <Vx2.z, Vy.z, Vz2.z>;
  <vdot(Apos, B1), vdot(Apos, B2), vdot(Apos, B3)> + axis1
#end

// End POV code


Post a reply to this message

From: Peter Popov
Subject: Re: Req: a #macro to reorient a vector
Date: 29 Jan 1999 00:50:09
Message: <36b14ae6.25624249@news.povray.org>
On Thu, 28 Jan 1999 23:49:00 -0500, Jerry Anning <cle### [at] dholcom>
wrote:

>Peter Popov wrote:
>> So, if you
>> can please tweak it so that it takes as parameters not T, but three
>> vectors - axis1, axis2 and point, axis1 and axis2 being H(T) and
>> H(T+dT), and point being A(T), you will do me a great favor.
>
>Try the following.
>
>Jerry Anning
>cle### [at] dholcom
>
>//Begin POV code

Give the same error, "degenerate cylinder, base point = apex point",
seems like I'm doing something wrong. I'll dig into the thing and
start bug-hunting. Be back tomorrow.

Peter


Post a reply to this message

Goto Latest 10 Messages Next 2 Messages >>>

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