|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
/*
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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> "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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"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
|
|
| |
| |
|
|
|
|
| |
|
|