POV-Ray : Newsgroups : povray.advanced-users : i still do not have an answer yet Server Time
30 Jul 2024 00:21:39 EDT (-0400)
  i still do not have an answer yet (Message 5 to 14 of 14)  
<<< Previous 4 Messages Goto Initial 10 Messages
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

From: Adam Gibbons
Subject: Re: i still do not have an answer yet
Date: 15 Jan 2001 20:43:27
Message: <3a63a73f@news.povray.org>
does vrotate work under povray 3.1g for windows ??!!

"Warp" <war### [at] tagpovrayorg> wrote in message
news: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

From: Chris Huff
Subject: Re: i still do not have an answer yet
Date: 15 Jan 2001 21:47:26
Message: <chrishuff-42A9CF.21484915012001@news.povray.org>
In article <3a63a73f@news.povray.org>, "Adam Gibbons" 
<Fie### [at] emailcom> wrote:

> does vrotate work under povray 3.1g for windows ??!!

Yes, the vrotate() function is part of the official version. However, 
the vtransform() function isn't, it is a patch that I wrote, but it is 
in MegaPOV and will eventually be in POV 3.5. You could imitate it 
partially with macros, like:
#macro VTranslate(V, Translation) (V+Translation) #end
#macro VScale(V, Translation) (V*Translation) #end

Another function in the official version that you may find useful is 
vaxis_rotate(), which rotates a point around a given axis by a specified 
number of degrees instead of x, y, then z.

-- 
Christopher James Huff
Personal: chr### [at] maccom, http://homepage.mac.com/chrishuff/
TAG: chr### [at] tagpovrayorg, http://tag.povray.org/

<><


Post a reply to this message

From: Warp
Subject: Re: i still do not have an answer yet
Date: 16 Jan 2001 11:46:19
Message: <3a647ada@news.povray.org>
Chris Huff <chr### [at] maccom> wrote:
: #macro VScale(V, Translation) (V*Translation) #end

  Your choice of parameter name is not the best possible ;)

: Another function in the official version that you may find useful is 
: vaxis_rotate(), which rotates a point around a given axis by a specified 
: number of degrees instead of x, y, then z.

  A macro that applies an axis_rotate to an object is not too difficult to
do either (I think someone has already done it; and it can be found in
the matrix page iirc).

-- 
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: Chris Huff
Subject: Re: i still do not have an answer yet
Date: 16 Jan 2001 15:50:32
Message: <chrishuff-3F5C60.15513516012001@news.povray.org>
In article <3a647ada@news.povray.org>, Warp <war### [at] tagpovrayorg> 
wrote:

> : #macro VScale(V, Translation) (V*Translation) #end
> 
>   Your choice of parameter name is not the best possible ;)

That's what I get for copy-pasting too much... :-)


>   A macro that applies an axis_rotate to an object is not too difficult 
> to do either (I think someone has already done it; and it can be 
> found in the matrix page iirc).

There is one on the Thoroughly Useful Macros page, it's called 
AxisRotate().
http://enphilistor.users4.50megs.com/macs.htm

-- 
Christopher James Huff
Personal: chr### [at] maccom, http://homepage.mac.com/chrishuff/
TAG: chr### [at] tagpovrayorg, http://tag.povray.org/

<><


Post a reply to this message

<<< Previous 4 Messages Goto Initial 10 Messages

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