POV-Ray : Newsgroups : povray.advanced-users : matrix help.... : Re: matrix help.... Server Time
29 Jul 2024 22:23:43 EDT (-0400)
  Re: matrix help....  
From: Paul Jones
Date: 14 Sep 2000 13:49:46
Message: <39C10F02.54866ECD@psu.edu>
Does this assume that your object is not located somewhere else other
than the origin? (<0,0,0>)  What if I have a gun turret that is located
at <5,0,5> (ie: it rotates around the line defined by <5,y,5>), would
this macro take that in to account? or would another parameter
_location_ be required? 

-paul 

John VanSickle wrote:
> 
> David Fontaine wrote:
> >
> > John's macro should do what you want. The only problem I think would be the axial
> > rotation changing, but if your gun stays pointing on the x-z plane with y up it
> > shouldn't matter I think. I've written one aimilar to keep axial rotation the same
> > (perpendicular vector intersecting y axis still intersects y axis). It's a lot
> > messier than John's though.
> 
> The Reorient vector tilts as if the joint were a ball-and-socket joint.  If you
> want to tilt in the way the POV camera tilts when the look_at parameter is
> specified, here is some tighter, neater, and more flexible code.
> 
> Specifically, it allows you to begin from any direction; this is useful because
> sometimes I model with x=forward, and sometimes with z=forward.  The "up"
> direction of your scene can also be specified, so this can be used by people
> who use up=y or up=z (or up=<3,4,12>/13, if you want to be strange).
> 
> I should probably add this to the Thoroughly Useful Macros file...
> 
> Hope this helps,
> John
> 
> // macro code follows
> 
> #macro PointAlong(OldDirection,NewDirection,Up)
> // OldDirection is the direction in which the object is currently pointed
> // NewDirection is the direction in which you want it to point
> // Up is the vector that is considered to be up
> 
> #if(vlength(OldDirection)=0)
> #error "Zero-length vector supplied as old direction.\n"
> #end
> #if(vlength(NewDirection)=0)
> #error "Zero-length vector supplied as new direction.\n"
> #end
> #if(vlength(Up)=0)
> #error "Zero-length vector supplied as up vector.\n"
> #end
> 
> #local vOD=vnormalize(OldDirection);
> #local vOR=vcross(Up,OldDirection);
> #if(vlength(vOR)=0)
>   #debug "Old direction vector is parallel to up vector.\n"
>   #local vOR=vcross(vOD,<vOD.z,vOD.x,-vOD.y>);
> #end
> #local vOR=vnormalize(vOR);
> #local vOU=vnormalize(vcross(OldDirection,vOR));
> 
> #local vND=vnormalize(NewDirection);
> #local vNR=vcross(Up,NewDirection);
> #if(vlength(vNR)=0)
>   #debug "New direction vector is parallel to up vector.\n"
>   #local vNR=vcross(vND,<vND.z,vND.x,-vND.y>);
> #end
> #local vNR=vnormalize(vNR);
> #local vNU=vnormalize(vcross(NewDirection,vOR));
> 
> matrix <vOR.x,vOU.x,vOD.x, vOR.y,vOU.y,vOD.y, vOR.z,vOU.z,vOD.z, 0,0,0>
> matrix <vOR.x,vOR.y,vOR.z, vOU.x,vOU.y,vOU.z, vOD.x,vOD.y,vOD.z, 0,0,0>
> 
> #end
> // end of macro code

-- 



--------------------------------------------------}
Paul Daniel Jones
The Pennslyvania State University

pdj### [at] psuedu
http://research.chem.psu.edu/glassgrp/paul

       C            The way is near, but men
     // \           seek it afar. It is in the
    N    N          easy things, but men seek it
    |    ||         in the difficult things.
    C    C          -Menicius
     \\  /
       C
--------------------------------------------------}


Post a reply to this message

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