POV-Ray : Newsgroups : povray.general : Transform help please Server Time
5 Nov 2024 01:23:11 EST (-0500)
  Transform help please (Message 1 to 10 of 10)  
From: Alf Peake
Subject: Transform help please
Date: 28 Aug 2003 17:31:24
Message: <3f4e74ac@news.povray.org>
/*
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
*/

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
// I think the error is here?
#declare Up = <-degrees( atan2( FaceN.z, FaceN.y) ),
                0,
                degrees( asin( FaceN.x/vlength(FaceN) ) )>;

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 = vrotate(P1, Up);
#declare Pb = vrotate(P2, Up);
#declare Pc = vrotate(P3, Up);
#declare Pd = vrotate(P4, Up);
#declare Pe = vrotate(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>)
   rotate -Up
}


Post a reply to this message

From: JC (Exether)
Subject: Re: Transform help please
Date: 29 Aug 2003 03:01:36
Message: <3f4efa50@news.povray.org>
I'm not quite sure what you want to do, but I have a few remarks that 
could give you some hints:
- Are you sure the face's points are coplanar ? (I guess you are, but 
it's still worth asking)
- 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 not as 
error prone. Basically I don't what the Up vector should be, so it's 
difficult to point out a potential error.

Good luck, I know these kind of bugs are really annoying,

JC

Alf Peake wrote:
> /*
> 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
> */
> 
> 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
> // I think the error is here?
> #declare Up = <-degrees( atan2( FaceN.z, FaceN.y) ),
>                 0,
>                 degrees( asin( FaceN.x/vlength(FaceN) ) )>;
> 
> 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 = vrotate(P1, Up);
> #declare Pb = vrotate(P2, Up);
> #declare Pc = vrotate(P3, Up);
> #declare Pd = vrotate(P4, Up);
> #declare Pe = vrotate(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>)
>    rotate -Up
> }
> 
> 
>


Post a reply to this message

From: Alf Peake
Subject: Re: Transform help please
Date: 29 Aug 2003 07:04:08
Message: <3f4f3328@news.povray.org>
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

From: JC (Exether)
Subject: Re: Transform help please
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

From: Alf Peake
Subject: Re: Transform help please
Date: 29 Aug 2003 10:45:46
Message: <3f4f671a@news.povray.org>
"JC (Exether)" <no### [at] spamfr> wrote in message
news:3f4f5b7a@news.povray.org...
> Speaking is easy, doing is better, so I did it.  :-)
> It seems to be what you wanted.
>
> #include "transforms.inc"
>
> #declare Up = transform { Reorient_Trans(FaceN, y) };

Thank you. That looks OK.
I realy should spend some time looking thru' the new includes in 3.5.

Alf


Post a reply to this message

From: Anton Sherwood
Subject: Re: Transform help please
Date: 29 Aug 2003 21:39:16
Message: <3f500044@news.povray.org>
> "JC (Exether)" <no### [at] spamfr> wrote
>> I'm not quite sure what you want to do,

Alf Peake wrote:
> Basicly, making a polyhedron with thick faces. Well, OK, a buckyball.

Why not just define a solid model (centred at the origin) and subtract a 
smaller from a bigger?

Hm, my http://www.ogre.nu/source/platon.inc has most of what you'd need 
for that;

#declare Soccer = intersection {
	#declare i=0;
	#while (i<6)
		plane { SixAxes[i], RP }
		plane { -SixAxes[i], RP }
		#declare i = i+1;
	#end//while
	#declare i=0;
	#while (i<10)
		plane { TenAxes[i], RH }
		plane { -TenAxes[i], RH }
		#declare i = i+1;
	#end//while
	}

difference { object {Soccer} object {Soccer scale 0.95} }

...I just don't know the appropriate ratio between RP and RH
(though I suppose I could derive it).

...On another hand, this sort of transform may be just what I'd need for 
an idea that has kicked around in back of my mind: a gothic Fuller dome.

-- 
Anton Sherwood, http://www.ogre.nu/


Post a reply to this message

From: Alf Peake
Subject: Re: Transform help please
Date: 30 Aug 2003 09:52:16
Message: <3f50ac10@news.povray.org>
"Anton Sherwood" <new### [at] ogrenu> wrote in message
news:3f500044@news.povray.org...

> Why not just define a solid model (centred at the origin) and
subtract a
> smaller from a bigger?

That's too easy :-) I wanted to be able to manipulate each face. Just
doodling.

> Hm, my http://www.ogre.nu/source/platon.inc has most of what you'd
need
> for that;

I'll look at that. Thanks.

OT: I was playing with data I found at
http://www.ccl.net/cca/data/fullerenes/index.shtml

Started with C30 data until I figured not all faces have coplanar
vertices. I'll stay with C20 data for now, maybe try C540 later.
I see from your website you like this subject :-) but I'm just
"passing by".

Alf


Post a reply to this message

From:
Subject: Re: Transform help please
Date: 31 Aug 2003 21:30:11
Message: <3f52a123@news.povray.org>
Hi Alf,

your declaration of the Up variable is correct, but to undo a

   rotate Up

which is the same as

   rotate Up.x*x // or <Up.x, 0, 0>
   rotate Up.y*y // or <0, Up.y, 0>; in your code, Up.y=0
   rotate Up.z*z // or <0, 0, Up.z>

you will have to undo these rotations in *reverse* order, i.e.

   rotate -Up.z*z
   rotate -Up.y*y
   rotate -Up.x*x

so the mistake is in the next-to-last line: replace

   rotate -Up

by
   rotate -Up.z*z
   rotate -Up.x*x

(rotate -Up.y*y is not required here because Up.y=0)
This will work as intended.

   Sputnik


Post a reply to this message

From: Christopher James Huff
Subject: Re: Transform help please
Date: 1 Sep 2003 00:27:04
Message: <cjameshuff-46883C.00270301092003@netplex.aussie.org>
In article <3f52a123@news.povray.org>,


> you will have to undo these rotations in *reverse* order, i.e.
> 
>    rotate -Up.z*z
>    rotate -Up.y*y
>    rotate -Up.x*x

Or "transform {rotate Up inverse}". Besides being shorter, it says 
exactly what it's doing and is far less error-prone, especially when 
you're editing the code.

Even better would be to declare the transformation. That way, you only 
need to edit one bit of code to change it.

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tagpovrayorg
http://tag.povray.org/


Post a reply to this message

From: Alf Peake
Subject: Re: Transform help please
Date: 1 Sep 2003 09:27:45
Message: <3f534951$1@news.povray.org>
"Christopher James Huff" <cja### [at] earthlinknet> wrote in message
news:cja### [at] netplexaussieorg...
> In article <3f52a123@news.povray.org>,

>
> > you will have to undo these rotations in *reverse* order, i.e.

Yes, I had figured that. I was put off because it worked OK around 50%
of the time.

> Or "transform {rotate Up inverse}". Besides being shorter, it says

Thank you for that. Another item I was unaware of. Realy must RTFM
again.

Alf


Post a reply to this message

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