POV-Ray : Newsgroups : povray.newusers : vector math Server Time
4 Nov 2024 17:31:05 EST (-0500)
  vector math (Message 1 to 2 of 2)  
From: Alan Walkington
Subject: vector math
Date: 7 Apr 2003 04:20:23
Message: <3e9134c7$1@news.povray.org>
Among the many thousands of things about povray that I don't seem to
understand appears to be use of the vector macros.

I want to create a cylinder along the x-axis with one end at 0,0.
move it to <location>,  pointed at <lookat>.

I /think/ I am doing the following:

1) find angle between <location> and <lookat> using VAngleD.
2) rotate the cylinder using that result.
3)  translate to <location>

Well, the cylinder doesn't appear to be rotating at all!
Probably something foolish that I am overlooking in the middle of the night.
Any help appreciated!

Alan Walkington
------------------
#include "colors.inc"
#include "math.inc"

light_source {
  0*x
  color White * 2
  translate <10, 20, 30>
}
plane {y, -1.0 pigment {color Gray65}}
camera {
    orthographic
    location  <0, 10,0>
    look_at   <0,0,0>
}

#macro Cylinder (Location, Lookat)
    #local len = VDist(Location, Lookat);
    cylinder {
        <0,0,0>
        <-len/2, 0, 0>
        .25
        pigment {color LightBlue}
        rotate VAngleD(Location, Lookat)
        translate Location
    }
#end

#declare Loc = <-2,0,2>;
#declare Look = <2,0,-2>;

// some markers
sphere {
    Loc .5
    pigment {color Red}

}
sphere {
    Look .5
    pigment {color Green}

}

// and the cylinder
Cylinder(Loc, Look)


Post a reply to this message

From: Christoph Hormann
Subject: Re: vector math
Date: 7 Apr 2003 07:18:18
Message: <3E915E7A.593BA21@gmx.de>
Alan Walkington wrote:
> 
> Among the many thousands of things about povray that I don't seem to
> understand appears to be use of the vector macros.
> 
> I want to create a cylinder along the x-axis with one end at 0,0.
> move it to <location>,  pointed at <lookat>.
> 
> [...]

You need to do a Reorient_Trans() with 'x' and '<lookat>-<location>'  as
parameters and then translate the object to <location>.

Christoph

-- 
POV-Ray tutorials, include files, Sim-POV,
HCR-Edit and more: http://www.tu-bs.de/~y0013390/
Last updated 28 Feb. 2003 _____./\/^>_*_<^\/\.______


Post a reply to this message

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