POV-Ray : Newsgroups : povray.general : Transform help please : Re: Transform help please Server Time
4 Nov 2024 23:19:41 EST (-0500)
  Re: Transform help please  
From: JC (Exether)
Date: 29 Aug 2003 09:56:10
Message: <3f4f5b7a@news.povray.org>
Speaking is easy, doing is better, so I did it.  :-)
It seems to be what you wanted.

JC

-------------
/*
Please help an old man whose brain is off-line
Wanted: a prism from 5 points on a plane.
Why doesn't this always work?
TIA

Alf
*/

#include "transforms.inc"

camera{ location <-1, 2,-4> look_at <0,0,0> }
light_source{ <-100,100,-100> 1 }

#declare OK = 1; // 0/1 = Not OK/OK.
#if (OK = 1)
   #declare P1 = < 1.170639, 1.170639, 1.170639>;
   #declare P2 = < 1.894104, 0.000000, 0.723495>;
   #declare P3 = < 1.894104, 0.000000,-0.723495>;
   #declare P4 = < 1.170639, 1.170639,-1.170639>;
   #declare P5 = < 0.723495, 1.894104, 0.000000>;
#else
   #declare P1 = <-1.170639, 1.170639, 1.170639>;
   #declare P2 = <-1.894104, 0.000000, 0.723495>;
   #declare P3 = <-1.170639,-1.170639, 1.170639>;
   #declare P4 = < 0.000000,-0.723495, 1.894104>;
   #declare P5 = < 0.000000, 0.723495, 1.894104>;
#end

#declare Avg = (P1+P2+P3+P4+P5)/5; // Face center
#declare FaceN = vcross(P1-P2, P1-P3); // Face normal

#declare Up = transform { Reorient_Trans(FaceN, y) };

union{ // Show original points.
   sphere{ P1, 0.1 }
   sphere{ P2, 0.1 }
   sphere{ P3, 0.1 }
   sphere{ P4, 0.1 }
   sphere{ P5, 0.1 }
   pigment{ rgb <1,0,1> }
}

// Rotate 5 points to be above and parallel to y-plane.
#declare Pa = vtransform(P1, Up);
#declare Pb = vtransform(P2, Up);
#declare Pc = vtransform(P3, Up);
#declare Pd = vtransform(P4, Up);
#declare Pe = vtransform(P5, Up);

// Show points on y-plane.
union{
   sphere{ <Pa.x, 0, Pa.z>, 0.1 }
   sphere{ <Pb.x, 0, Pb.z>, 0.1 }
   sphere{ <Pc.x, 0, Pc.z>, 0.1 }
   sphere{ <Pd.x, 0, Pd.z>, 0.1 }
   sphere{ <Pe.x, 0, Pe.z>, 0.1 }
   pigment{ rgb <0,1,1> }
}

// Now transform a prism to match original points.
prism{ -0.05, 0.05, 5+1,
   <Pa.x, Pa.z>,
   <Pb.x, Pb.z>,
   <Pc.x, Pc.z>,
   <Pd.x, Pd.z>,
   <Pe.x, Pe.z>,
   <Pa.x, Pa.z>
   pigment{ rgb <1,1,0> }
   translate y*vlength(Avg) // y*(distance from <0,0,0>)
   transform { Reorient_Trans(y, FaceN) }
}


Alf Peake wrote:
> Hi
> 
> "JC (Exether)" <no### [at] spamfr> wrote in message
> news:3f4efa50@news.povray.org...
> 
>>I'm not quite sure what you want to do, but I have a few remarks
> 
> that
> 
> Basicly, making a polyhedron with thick faces. Well, OK, a buckyball.
> 
> 
>>- Are you sure the face's points are coplanar ?
> 
> 
> Yes.
> 
> 
>>- It is generaly better in POV scripts if you can use vectorial
> 
> (cross
> 
>>products, projections, transforms.inc macros and stuff like that)
>>formulaes instead of trigonometric, because it's clearer and it's
> 
> 
> I can never remember vectorial operations like vcross :-/ but can
> manage trig with a pencil & paper most times.
> 
> 
>>Basically I don't what the Up vector should be,
> 
> 
> Up is +y. I want to rotate any vector to point up.
> 
> 
>>Good luck,
> 
> 
> Thanks
> 
> Alf
> 
> 
>


Post a reply to this message

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