POV-Ray : Newsgroups : povray.programming : Making Torus Server Time: 12 Dec 2018 21:01:49 GMT
  Making Torus (Message 1 to 7 of 7)  
From: bakom
Subject: Making Torus
Date: 28 Aug 2014 02:55:00
Message: <web.53fe987873bfab70a0bda8a0@news.povray.org>
I am working on a converter that converts the BRL-CAD's objects in our POV-ray
format. I am able to convert sphere object of BRL-CAD into POV-ray's.
Now, in torus
BRL-CAD make a torus by using
center point, normal vector, inner radius and outer radius.
eg. Center : X Y Z
Normal Vector: X Y Z
Radius1: r1
Radius2: r2
I am able to convert it( by avoiding normal of brlcad's object ) but as in
BRL-CAD, using normal to torus we can align/rotate torus, is there any way to
make torus using normal in POV-ray? There is a rotation macro used to rotate it
but I want to use normal vector as it is.
In brlcad normal vector 1 0 0 makes a torus parellel to y axis. How can I do the
same?



Smile On!
Gurwinder Singh


Post a reply to this message

From: clipka
Subject: Re: Making Torus
Date: 28 Aug 2014 06:02:22
Message: <53fec5ee@news.povray.org>
Am 28.08.2014 04:49, schrieb bakom:
> I am working on a converter that converts the BRL-CAD's objects in our POV-ray
> format. I am able to convert sphere object of BRL-CAD into POV-ray's.
> Now, in torus
> BRL-CAD make a torus by using
> center point, normal vector, inner radius and outer radius.
> eg. Center : X Y Z
> Normal Vector: X Y Z
> Radius1: r1
> Radius2: r2
> I am able to convert it( by avoiding normal of brlcad's object ) but as in
> BRL-CAD, using normal to torus we can align/rotate torus, is there any way to
> make torus using normal in POV-ray? There is a rotation macro used to rotate it
> but I want to use normal vector as it is.

Nope, you need to apply a rotation.


Post a reply to this message

From: bakom
Subject: Re: Making Torus
Date: 12 Sep 2014 04:50:00
Message: <web.54127a75100ee5ff2af8b5cb0@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> Am 28.08.2014 04:49, schrieb bakom:
> > I am working on a converter that converts the BRL-CAD's objects in our POV-ray
> > format. I am able to convert sphere object of BRL-CAD into POV-ray's.
> > Now, in torus
> > BRL-CAD make a torus by using
> > center point, normal vector, inner radius and outer radius.
> > eg. Center : X Y Z
> > Normal Vector: X Y Z
> > Radius1: r1
> > Radius2: r2
> > I am able to convert it( by avoiding normal of brlcad's object ) but as in
> > BRL-CAD, using normal to torus we can align/rotate torus, is there any way to
> > make torus using normal in POV-ray? There is a rotation macro used to rotate it
> > but I want to use normal vector as it is.
>
> Nope, you need to apply a rotation.

Ok, but in torus.cpp file
https://github.com/POV-Ray/povray/blob/master/source/backend/shape/torus.cpp
there is a normal vector calculation at line number 358. So can we use it in any
way for making torus?
If plane is formed by using normal so why not torus in POV-ray?(general
question).


Post a reply to this message

From: Le Forgeron
Subject: Re: Making Torus
Date: 12 Sep 2014 06:45:36
Message: <54129690$1@news.povray.org>
Le 12/09/2014 06:45, bakom a écrit :
> clipka <ano### [at] anonymousorg> wrote:
>> Am 28.08.2014 04:49, schrieb bakom:
>>> I am working on a converter that converts the BRL-CAD's objects in our POV-ray
>>> format. I am able to convert sphere object of BRL-CAD into POV-ray's.
>>> Now, in torus
>>> BRL-CAD make a torus by using
>>> center point, normal vector, inner radius and outer radius.
>>> eg. Center : X Y Z
>>> Normal Vector: X Y Z
>>> Radius1: r1
>>> Radius2: r2
>>> I am able to convert it( by avoiding normal of brlcad's object ) but as in
>>> BRL-CAD, using normal to torus we can align/rotate torus, is there any way to
>>> make torus using normal in POV-ray? There is a rotation macro used to rotate it
>>> but I want to use normal vector as it is.
>>
>> Nope, you need to apply a rotation.
> 
> Ok, but in torus.cpp file
> https://github.com/POV-Ray/povray/blob/master/source/backend/shape/torus.cpp
> there is a normal vector calculation at line number 358. So can we use it in any
> way for making torus?
> If plane is formed by using normal so why not torus in POV-ray?(general
> question).

It seems that you are asking for something similar to mesh2 / mesh : a
different syntax for the same object.

Excepted that the parser does not have to be patched in your situation:
make a macro which will take your parameters and make the needed
transcriptions in the SDL as it is today.

it might be something like:

#include "transform.inc"
#macro TorusBRL(Center, Normal, Radius1, Radius2)
torus {
Radius1, Radius2 // at <0,0,0>, normal as y
Reorient_Trans(y, Normal) // still at <0,0,0>, normal as Normal
translate Center // now at the right place and orientation
}
#end

Then you need some trick like

object { TorusBRL(...) texture { pigment { color Yellow } finish {
Glossy } } }

to texture it.

Or you add a fifth parameter to the macro, to pass extra tokens ? (I
wonder if it works or not)
Or you make the macro ill-balanced in regard to opening and closing braces.

-- 
Just because nobody complains does not mean all parachutes are perfect.


Post a reply to this message

From: clipka
Subject: Re: Making Torus
Date: 12 Sep 2014 13:02:02
Message: <5412eeca$1@news.povray.org>
Am 12.09.2014 06:45, schrieb bakom:
> clipka <ano### [at] anonymousorg> wrote:
>> Am 28.08.2014 04:49, schrieb bakom:
>>> I am working on a converter that converts the BRL-CAD's objects in our POV-ray
>>> format. I am able to convert sphere object of BRL-CAD into POV-ray's.
>>> Now, in torus
>>> BRL-CAD make a torus by using
>>> center point, normal vector, inner radius and outer radius.
>>> eg. Center : X Y Z
>>> Normal Vector: X Y Z
>>> Radius1: r1
>>> Radius2: r2
>>> I am able to convert it( by avoiding normal of brlcad's object ) but as in
>>> BRL-CAD, using normal to torus we can align/rotate torus, is there any way to
>>> make torus using normal in POV-ray? There is a rotation macro used to rotate it
>>> but I want to use normal vector as it is.
>>
>> Nope, you need to apply a rotation.
>
> Ok, but in torus.cpp file
> https://github.com/POV-Ray/povray/blob/master/source/backend/shape/torus.cpp
> there is a normal vector calculation at line number 358. So can we use it in any
> way for making torus?

No; the "normal vector calculation" in there computes the "surface 
normal" for a given point, not the normal vector of the plane on which 
the torus lies.

> If plane is formed by using normal so why not torus in POV-ray?(general
> question).

The mathematical formula for computing the intersection of a ray with a 
torus is complicated enough as it is, so this is simply how the torus 
object is implemented.

Theoretically it would be possible to allow for a vector to be 
specified, and automatically convert that into a corresponding rotation 
matrix; however, that would have to be done in the parser, which is ugly 
and kludgy enough already, so we try to avoid changes in there.


Post a reply to this message

From: bakom
Subject: Re: Making Torus
Date: 20 Sep 2014 02:55:00
Message: <web.541cebed100ee5ff949ffef10@news.povray.org>
Le_Forgeron <lef### [at] freefr> wrote:
> Le 12/09/2014 06:45, bakom a écrit :
> > clipka <ano### [at] anonymousorg> wrote:

<snip>

> Excepted that the parser does not have to be patched in your situation:
> make a macro which will take your parameters and make the needed
> transcriptions in the SDL as it is today.
>
> it might be something like:
>
> #include "transform.inc"
> #macro TorusBRL(Center, Normal, Radius1, Radius2)
> torus {
> Radius1, Radius2 // at <0,0,0>, normal as y
> Reorient_Trans(y, Normal) // still at <0,0,0>, normal as Normal
> translate Center // now at the right place and orientation
> }
> #end
>
> Then you need some trick like
>
> object { TorusBRL(...) texture { pigment { color Yellow } finish {
> Glossy } } }
>
> to texture it.

Thanks a lot for this. Very helpful to me.
So, I can make a macro for azimuth and elevation?
I am trying to write a macro in which I rotate the camera by using rotation as
#macro Set_Camera_rotation { <angle>}.
But need some more knowledge for making this.


Post a reply to this message

From: bakom
Subject: Re: Making Torus
Date: 21 Sep 2014 15:30:00
Message: <web.541eee3e100ee5ffe8a41cbe0@news.povray.org>
"bakom" <gswithbains> wrote:
> Le_Forgeron <lef### [at] freefr> wrote:
> > Le 12/09/2014 06:45, bakom a écrit :
> > > clipka <ano### [at] anonymousorg> wrote:
>
> <snip>
>
> > Excepted that the parser does not have to be patched in your situation:
> > make a macro which will take your parameters and make the needed
> > transcriptions in the SDL as it is today.
> >
> > it might be something like:
> >
> > #include "transform.inc"
> > #macro TorusBRL(Center, Normal, Radius1, Radius2)
> > torus {
> > Radius1, Radius2 // at <0,0,0>, normal as y
> > Reorient_Trans(y, Normal) // still at <0,0,0>, normal as Normal
> > translate Center // now at the right place and orientation
> > }
> > #end
> >
> > Then you need some trick like
> >
> > object { TorusBRL(...) texture { pigment { color Yellow } finish {
> > Glossy } } }
> >
> > to texture it.
>
> Thanks a lot for this. Very helpful to me.
> So, I can make a macro for azimuth and elevation?
> I am trying to write a macro in which I rotate the camera by using rotation as
> #macro Set_Camera_rotation { <angle>}.
> But need some more knowledge for making this.

How to write it?


Post a reply to this message

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