POV-Ray : Newsgroups : povray.advanced-users : i still do not have an answer yet Server Time
26 Nov 2024 04:28:00 EST (-0500)
  i still do not have an answer yet (Message 1 to 10 of 14)  
Goto Latest 10 Messages Next 4 Messages >>>
From: Adam Gibbons
Subject: i still do not have an answer yet
Date: 13 Jan 2001 15:39:33
Message: <3a60bd05@news.povray.org>
hi there my name is Adam and I am currently working on this POV-RAY picture.
but I am stuck, before I tell you what I am stuck on I thought I should give
you some back ground info on what it is I am stuck on. just so you know what
it is I am going on about.

if we take for example: - (this simple shape)

sphere
{

<0.68,(0.425/2)+0.09,0>0.1
translate <0,0.85,0>
scale <0.75,0.75,0.75>
rotate < 10 ,-45, -20>
translate <-0.7,-0.1, 00>
pigment{Red}
}

you can see that its position in 3D space is given by many commands, first a
location which is moved then rotated and then scaled and then moved again.
by this time the shape is getting dizzy.

but through extrapolation you can eliminate each of these steps to exactly
the same shape in the same XYZ coordinates and the same size.

E.G..

<0.68,(0.425/2)+0.09,0> translated by <0,0.85,0> becomes <0.68,0.3025,0.00>

<0.68,(0.425/2)+0.09,0>
+                   <0,0.85,0>
=      <0.68,0.3025,0.00>

do you see ?? well I hope so because that is just the beginning....

NEXT

<0.68,0.3025,0.00> is Scaled by <0.75,0.75,0.75> which can be turned into
<0.51,0.8643750,0.00>
<0.68,0.3025,0.00>
*  <0.75,0.75,0.75>
= <0.51,0.8643750,0.00>

SO if we now uses the code: -

 <0.51,0.8643750,0>0.1
 rotate < 10 ,-45, -20>
 translate <-0.7,-0.1, 00>
 pigment{Red}
 }

basically all we have done is taken

(  <0.68,(0.425/2)+0.09,0>  +  <0,0.85,0>  )  *  <0.75,0.75,0.75

= <0.51,0.8643750,0>

 [ we have extrapolated these new co-ordinates from some existing ones and a
set of instructions ]

we get exactly the same shape in the same place and it is much easier to
understand exactly where it is.

but this is where I get stuck you may notice there is a rotation left in the
statement, and also another translation. I can do the translation that is
easy. It is the rotation that I am finding hard. as you will know if you
move an object and then choose to rotate it, it rotates as through a piece
of string is attached to <0,0,0> what is that I here you say why not rotate
the object before I move it. well because then it will not be in the exact
right place and I will have to start moving it little by little in my scene
to get it in just the right place. and that would take far to long. what I
need is a way or a formula so that I can take my existing co-ordinates and
then by using some method of rotational extrapolation gain the new set of
co-ordinates. in a similar way that I managed to do the examples above.

if some one out there can tell me how you do this then not only would I be
most grateful BUT I will make a windows application that will allow people
to easily do extrapolation in the future and I will make it totally free for
every one at POV-RAY to use. that is after I have finished making the dam
thing.

please there must be some POV-RAY guru out there that can help me
extrapolate these new co-ordinates from this rotational statement. if you
can help me then please feel free to email me at this address
Fie### [at] emailcom

thanks

Adam =B)


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: i still do not have an answer yet
Date: 13 Jan 2001 16:00:07
Message: <3A60C099.6C18C053@online.no>
Adam Gibbons wrote:
> 
> <0.68,(0.425/2)+0.09,0>
> +                   <0,0.85,0>
> =      <0.68,0.3025,0.00>

<0.68, 0.425/2 + 0.09, 0> + <0, 0.85, 0> = <0.68, 1.1525, 0>


> <0.68,0.3025,0.00>
> *  <0.75,0.75,0.75>
> = <0.51,0.8643750,0.00>

0.75 * <0.68, 0.3025, 0> = <0.51, 0.226875, 0>


:)

Regards,

Tor Olav
-- 
mailto:tor### [at] hotmailcom
http://www.crosswinds.net/~tok/tokrays.html


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: i still do not have an answer yet
Date: 13 Jan 2001 16:24:43
Message: <3A60C65E.4C16299@online.no>
Adam Gibbons wrote:
> 
>...
> 
> but this is where I get stuck you may notice there is a rotation left in the
> statement, 

Ehh... No. Not ONE rotation "left".


When you do this;

sphere {
  <0.51, 0.8643750, 0>, 0.1
  rotate <10, -45, -20>
}

you make 3 rotations of the sphere relative to the axes.

First the sphere is rotated 10 degrees around the x-axis.
Then it is rotated -45 degrees around the y-axis.
And then -20 degrees around the z-axis.


And yes, you can use your "string" idea to visualize how 
they are rotated.

In the fist rotation your string is attached to the 
closest point on the x-axis.

In the second rotation your string is attached to the 
point that now has become the closest point on the y-axis. 

And in the third rotation your string is attached point 
that now has become the closest point on the z-axis.


(To see which way a rotation will go around an axis, 
let your left hand thumb point in the direction of the 
axis in question, and then look at the other fingers 
of your left hand. They will now point in the direction 
that the rotation will go if the angle is positive.)


If I can find some more spare time tomorrow, then I'll 
try to explain the calculations of the rotations.

Regards,

Tor Olav
-- 
mailto:tor### [at] hotmailcom
http://www.crosswinds.net/~tok/tokrays.html


Post a reply to this message

From: Adam Gibbons
Subject: Re: i still do not have an answer yet
Date: 13 Jan 2001 20:07:32
Message: <3a60fbd4@news.povray.org>
Thanks very much for you help. i have had a kit of usesless replys. but
yours it very help full.

i would very much appiciate it if you can provide me with a formula for what
i have written.


"Tor Olav Kristensen" <tor### [at] onlineno> wrote in message
news:3A6### [at] onlineno...
>
> Adam Gibbons wrote:
> >
> >...
> >
> > but this is where I get stuck you may notice there is a rotation left in
the
> > statement,
>
> Ehh... No. Not ONE rotation "left".
>
>
> When you do this;
>
> sphere {
>   <0.51, 0.8643750, 0>, 0.1
>   rotate <10, -45, -20>
> }
>
> you make 3 rotations of the sphere relative to the axes.
>
> First the sphere is rotated 10 degrees around the x-axis.
> Then it is rotated -45 degrees around the y-axis.
> And then -20 degrees around the z-axis.
>
>
> And yes, you can use your "string" idea to visualize how
> they are rotated.
>
> In the fist rotation your string is attached to the
> closest point on the x-axis.
>
> In the second rotation your string is attached to the
> point that now has become the closest point on the y-axis.
>
> And in the third rotation your string is attached point
> that now has become the closest point on the z-axis.
>
>
> (To see which way a rotation will go around an axis,
> let your left hand thumb point in the direction of the
> axis in question, and then look at the other fingers
> of your left hand. They will now point in the direction
> that the rotation will go if the angle is positive.)
>
>
> If I can find some more spare time tomorrow, then I'll
> try to explain the calculations of the rotations.
>
> Regards,
>
> Tor Olav
> --
> mailto:tor### [at] hotmailcom
> http://www.crosswinds.net/~tok/tokrays.html


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: i still do not have an answer yet
Date: 13 Jan 2001 23:16:43
Message: <3A6126E0.F5C4E9DE@online.no>
Adam Gibbons wrote:
> 
> Thanks very much for you help. i have had a kit of usesless replys. 

My opinion is that they weren't useless.

I belive they replied the way they did because you 
asked this kind of question in povray.advanced-users 
instead of in povray.newusers.   ;)


> but yours it very help full.
> 
> i would very much appiciate it if you can provide me with a formula for what
> i have written.

Now it's tomorrow here in Norway and I have had a few beers ...
So therefore I'll not try to give you a lengthy answer now.

But you may have a look at the code below and then feel free 
to ask if you need me to explain more.

Now I'm off to bed.


Regards,

Tor Olav
-- 
mailto:tor### [at] hotmailcom
http://www.crosswinds.net/~tok/tokrays.html

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#version 3.1;

#include "colors.inc"

#declare nothing = 1/10000;

#declare SphereRadius = 0.1;

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
// Like you did it

sphere {
  <0.68, 0.425/2 + 0.09, 0>, SphereRadius
  translate <0, 0.85, 0>
  scale 0.75
  rotate <10, -45, -20>
  translate <-0.7, -0.1, 0>
  pigment { Red }
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
// Use of vrotate to put sphere in same postion 

#declare pStart = (<0.68, 0.425/2 + 0.09, 0> + <0, 0.85, 0>)*0.75;

#declare pEnd = vrotate(pStart, <10, -45, -20>) + <-0.7, -0.1, 0>;

sphere {
  pEnd, SphereRadius*0.75 // - nothing
  pigment { Yellow }
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
// Doing it the "hard way" with trig functions

#declare pStart = (<0.68, 0.425/2 + 0.09, 0> + <0, 0.85, 0>)*0.75;

#declare xAngle = radians(10);
#declare yAngle = radians(-45);
#declare zAngle = radians(-20);

// Rotate around the x-axis
#declare pRot1 = <pStart.x,
                  cos(xAngle)*pStart.y - sin(xAngle)*pStart.z,
                  cos(xAngle)*pStart.z + sin(xAngle)*pStart.y>;
   
// Rotate around the y-axis
#declare pRot2 = <cos(yAngle)*pRot1.x  + sin(yAngle)*pRot1.z,
                  pRot1.y,
                  cos(yAngle)*pRot1.z  - sin(yAngle)*pRot1.x>

// Rotate around the z-axis
#declare pRot3 = <cos(zAngle)*pRot2.x  - sin(zAngle)*pRot2.y,
                  cos(zAngle)*pRot2.y  + sin(zAngle)*pRot2.x,
                  pRot2.z>

#declare pEnd = pRot3 + <-0.7, -0.1, 0>;

sphere {
  pEnd, SphereRadius*0.75 + nothing
  pigment { Green }
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
// Show start and end postition points in debug window

#macro PrintVector(Vector)

  #debug "<"
  #debug str(Vector.x, 0, -1)
  #debug ", "
  #debug str(Vector.y, 0, -1)
  #debug ", "
  #debug str(Vector.z, 0, -1)
  #debug ">"

#end // macro PrintVector


#debug "\n\n"
PrintVector(pStart)
#debug "\n\n"
PrintVector(pEnd)
#debug "\n\n"

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

light_source { 10*<3, -1, 1> color White }

background { color Blue/2 }

camera {
  location <1, 1, 1>
  look_at <0, 0, 0>
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7


Post a reply to this message

From: Warp
Subject: Re: i still do not have an answer yet
Date: 14 Jan 2001 07:43:06
Message: <3a619eda@news.povray.org>
I just don't understand why you want to make this. What will you achieve
doing it?
  Your rendering speed will not be affected in any way.
  You will only cause yourself more trouble than it's worth.

  If you keep the transformations that put the object in the right place,
it's easier to see how the location was calculated.
  Also, what happens if you want to slightly modify one of the transformations?
Instead of just modifying one number in the transformations you'll have to
recalculate the whole thing again. Why, when povray can do it for yourself?

  Of course it's good to know the math to get the location of a point which
have been transformed because it can have some uses, but in my experience
one of these uses is not putting the result directly in the object
definition.

-- 
char*i="b[7FK@`3NB6>B:b3O6>:B:b3O6><`3:;8:6f733:>::b?7B>:>^B>C73;S1";
main(_,c,m){for(m=32;c=*i++-49;c&m?puts(""):m)for(_=(
c/4)&7;putchar(m),_--?m:(_=(1<<(c&3))-1,(m^=3)&3););}    /*- Warp -*/


Post a reply to this message

From: Adam Gibbons
Subject: Re: i still do not have an answer yet
Date: 14 Jan 2001 09:02:33
Message: <3a61b179@news.povray.org>
You really want to know why ?? !

ok,

i am drawing a lamp.

i have the head of the lamp and i have the base of the lamp
but i have nothing connecting the two.

i can draw a sphere as a marker at the top and another at the bottem for
where i want the wire to goto and from. but the top of the lamp has been
move and then rotated. but to ray something going between to two i need jus
the X,Y,Z for the top and just the X,Y,Z for the bottem. i have to bottem
co-ordinets, but to work out what the top ones are i have to find the answer
to my problem.

plus it would be usesfull to know in the future for other sceans with maybe
a simaler problem.

if you know the answer then please just tell me.

Adam


"Warp" <war### [at] tagpovrayorg> wrote in message
news:3a619eda@news.povray.org...
>   I just don't understand why you want to make this. What will you achieve
> doing it?
>   Your rendering speed will not be affected in any way.
>   You will only cause yourself more trouble than it's worth.
>
>   If you keep the transformations that put the object in the right place,
> it's easier to see how the location was calculated.
>   Also, what happens if you want to slightly modify one of the
transformations?
> Instead of just modifying one number in the transformations you'll have to
> recalculate the whole thing again. Why, when povray can do it for
yourself?
>
>   Of course it's good to know the math to get the location of a point
which
> have been transformed because it can have some uses, but in my experience
> one of these uses is not putting the result directly in the object
> definition.
>
> --
> char*i="b[7FK@`3NB6>B:b3O6>:B:b3O6><`3:;8:6f733:>::b?7B>:>^B>C73;S1";
> main(_,c,m){for(m=32;c=*i++-49;c&m?puts(""):m)for(_=(
> c/4)&7;putchar(m),_--?m:(_=(1<<(c&3))-1,(m^=3)&3););}    /*- Warp -*/


Post a reply to this message

From: Francois Labreque
Subject: Re: i still do not have an answer yet
Date: 14 Jan 2001 09:22:17
Message: <3A61B595.9D258E29@videotron.ca>
Adam Gibbons wrote:
> 
> plus it would be usesfull to know in the future for other sceans with maybe
> a simaler problem.
> 
> if you know the answer then please just tell me.

David Fontaine already did:

	This is basically vectors and matrices.

	The matrices for the different transforms and a basic explana-
	tion of how they work is here, but it won't tell you the basics
	of matrix math like multiplying, etc: 
	http://davidf.faricy.net/povre.html#Matrices (nothing like a
	little website promotion)

As did Tor Olav Kristensen:

	// Rotate around the x-axis
	#declare pRot1 = <pStart.x,
            cos(xAngle)*pStart.y - sin(xAngle)*pStart.z,
            cos(xAngle)*pStart.z + sin(xAngle)*pStart.y>;
   
	// Rotate around the y-axis
	#declare pRot2 = <cos(yAngle)*pRot1.x  + sin(yAngle)*pRot1.z,
            pRot1.y,
            cos(yAngle)*pRot1.z  - sin(yAngle)*pRot1.x>

	// Rotate around the z-axis
	#declare pRot3 = <cos(zAngle)*pRot2.x  - sin(zAngle)*pRot2.y,
            cos(zAngle)*pRot2.y  + sin(zAngle)*pRot2.x,
            pRot2.z>

And I remember someone else providing these equations to Rune as well in
an other thread.




> 
> Adam
> 
> "Warp" <war### [at] tagpovrayorg> wrote in message
> news:3a619eda@news.povray.org...
> >   I just don't understand why you want to make this. What will you achieve
> > doing it?
> >   Your rendering speed will not be affected in any way.
> >   You will only cause yourself more trouble than it's worth.
> >
> >   If you keep the transformations that put the object in the right place,
> > it's easier to see how the location was calculated.
> >   Also, what happens if you want to slightly modify one of the
> transformations?
> > Instead of just modifying one number in the transformations you'll have to
> > recalculate the whole thing again. Why, when povray can do it for
> yourself?
> >
> >   Of course it's good to know the math to get the location of a point
> which
> > have been transformed because it can have some uses, but in my experience
> > one of these uses is not putting the result directly in the object
> > definition.
> >
> > --
> > char*i="b[7FK@`3NB6>B:b3O6>:B:b3O6><`3:;8:6f733:>::b?7B>:>^B>C73;S1";
> > main(_,c,m){for(m=32;c=*i++-49;c&m?puts(""):m)for(_=(
> > c/4)&7;putchar(m),_--?m:(_=(1<<(c&3))-1,(m^=3)&3););}    /*- Warp -*/

-- 
Francois Labreque | Unfortunately, there's no such thing as a snooze
    flabreque     | button on a cat who wants breakfast.
        @         |      - Unattributed quote from rec.humor.funny
   videotron.ca


Post a reply to this message

From: Mark James Lewin
Subject: Re: i still do not have an answer yet
Date: 14 Jan 2001 16:26:37
Message: <3A6219A4.25658654@yahoo.com.au>
Adam, although this isn't a windows program that will do what you want, it may
be the nearest POV equivelent. You could try placing all of those transforms
into a transform identifier, then use that identifier to both move the sphere
_and_ calculate the new coordinates, then output those coords to a text stream
in the POV messages. The example below uses a MegaPOV feature (vtransform) but I
think the rest of the code is 3.1 compatible.

// 1st, declare all of your transformations
#declare Trans_1 =
transform
        {
        translate <0,0.85,0>
        scale <0.75,0.75,0.75>
        rotate < 10 ,-45, -20>
        translate <-0.7,-0.1, 00>
        }

// Calculate the new position using vtransform
#declare Sphere_Pos = vtransform(<0.68,(0.425/2)+0.09,0>,transform Trans_1);

// Stream the x,y, and z coords to the debug steam
#debug concat("\n","X Co-ord = ",str(Sphere_Pos.x,0,-1))
#debug concat("\n","Y Co-ord = ",str(Sphere_Pos.y,0,-1))
#debug concat("\n","Z Co-ord = ",str(Sphere_Pos.z,0,-1),"\n")

// Declare your sphere
sphere
        {
        <0.68,(0.425/2)+0.09,0>
        0.1

        texture { Your_Tex }

        transform Trans_1
        }

Now you have both a transformed sphere, and its new coordinates (both streamed
so that you can see them, and in the Sphere_Pos identifier). Hope this helps.

MJL


Post a reply to this message

From: Warp
Subject: Re: i still do not have an answer yet
Date: 15 Jan 2001 03:51:59
Message: <3a62ba2f@news.povray.org>
So what you want is just a vector telling you the location of the object.
You don't need to calculate the result by yourself but you can let povray
do it, as others have already answered.
  If you are using megapov, you can declare all the transformations in one
identifier and then apply the same transformation to the object and to
a vector (with vtransform), as already pointed out.
  It's also good to know how to make the individual transformations to a
vector:

translate <a,b,c>  <=>  #declare Vector = Vector + <a,b,c>;
    scale <a,b,c>  <=>  #declare Vector = Vector * <a,b,c>;
   rotate <a,b,c>  <=>  #declare Vector = vrotate(Vector, <a,b,c>);

  If you want to make the individual transformations to the vector (eg. because
you don't have megapov to use vtransform, or for other reason), just apply
the abovementioned equivalent operations.
  For example:

sphere
{ 0, 1  #declare Loc = <0,0,0>;
  translate <1,2,-3>  #declare Loc = Loc + <1,2,-3>;
  rotate y*30  #declare Loc = vrotate(Loc, y*30);
  translate -x*2  #declare Loc = Loc - x*2;
  scale .5  #declare Loc = Loc * .5;
}

  Now 'Loc' will be the coordinate of the center of the sphere.

-- 
char*i="b[7FK@`3NB6>B:b3O6>:B:b3O6><`3:;8:6f733:>::b?7B>:>^B>C73;S1";
main(_,c,m){for(m=32;c=*i++-49;c&m?puts(""):m)for(_=(
c/4)&7;putchar(m),_--?m:(_=(1<<(c&3))-1,(m^=3)&3););}    /*- Warp -*/


Post a reply to this message

Goto Latest 10 Messages Next 4 Messages >>>

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