POV-Ray : Newsgroups : povray.newusers : vector math : vector math Server Time
4 Nov 2024 13:02:50 EST (-0500)
  vector math  
From: Alan Walkington
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

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