POV-Ray : Newsgroups : povray.advanced-users : Macro in POV-ray Server Time
22 Dec 2024 16:08:44 EST (-0500)
  Macro in POV-ray (Message 1 to 6 of 6)  
From: bakom
Subject: Macro in POV-ray
Date: 17 Oct 2014 22:35:00
Message: <web.5441d0a9bcbb5a72e0d811940@news.povray.org>
I want to do azimuth and elevation so Rotate_Around_Trans() I think helps me.
But how to use it? Its not working when I write it as

Rotate_Around_Trans(1.x, 2.x, 3.x, 1, 0, 0).

How to make a macro in POV-ray? In documents I am unable to find it. Can I make
my own macro for azimuth and elevation?


Post a reply to this message

From: Bald Eagle
Subject: Re: Macro in POV-ray
Date: 18 Oct 2014 00:40:00
Message: <web.5441eeeb5ae0f3ce5e7df57c0@news.povray.org>
"bakom" <gswithbains> wrote:
> I want to do azimuth and elevation so Rotate_Around_Trans() I think helps me.
> But how to use it? Its not working when I write it as
>
> Rotate_Around_Trans(1.x, 2.x, 3.x, 1, 0, 0).
>
> How to make a macro in POV-ray? In documents I am unable to find it. Can I make
> my own macro for azimuth and elevation?

 Rotate_Around_Trans(Rotation, Point). Ordinary rotation operates around the
origin, this macro rotates around a specific point.
Parameters:

    Rotation = The rotation vector, the same as the parameter to the rotate
keyword.
    Point = The point to rotate around.


So,
#include "transforms.inc"
 object {My_Object Rotate_Around_Trans(z*90, <0, 0, 0>) }

would rotate around the z-axis like usual.

#include "transforms.inc"
 object {My_Object Rotate_Around_Trans(z*90, <5, 0, 0>) }

rotates around the z-axis where x=5.

Macros are kinda like a subroutine.
You define a macro by using the MACRO keyword

#macro My_Macro (d, e, f)
     #local g = d * 3;
     sphere {<d, e, f>, g}
#end

#declare a = 1;
#declare b = 2;
#declare c = 3;

My_Macro (a, b, c)

The values plugged into the macro (a, b, and c) are copied over to the macro
variables (e, f, and g) for use within the macro.
The macro variable g is only defined within the macro - outside of the macro g
is undefined.


Hit F1 or select HELP from the menu while running POV-Ray.
Search for macros - there's a whole section.
3.3.2.8 User Defined Macros


Post a reply to this message

From: bakom
Subject: Re: Macro in POV-ray
Date: 18 Oct 2014 22:10:01
Message: <web.54431b9f5ae0f3ce9532ba3c0@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> "bakom" <gswithbains> wrote:
> > I want to do azimuth and elevation so Rotate_Around_Trans() I think helps me.
> > But how to use it? Its not working when I write it as
> >
> > Rotate_Around_Trans(1.x, 2.x, 3.x, 1, 0, 0).
> >
> > How to make a macro in POV-ray? In documents I am unable to find it. Can I make
> > my own macro for azimuth and elevation?
>
>  Rotate_Around_Trans(Rotation, Point). Ordinary rotation operates around the
> origin, this macro rotates around a specific point.
> Parameters:
>
>     Rotation = The rotation vector, the same as the parameter to the rotate
> keyword.
>     Point = The point to rotate around.
>
>
> So,
> #include "transforms.inc"
>  object {My_Object Rotate_Around_Trans(z*90, <0, 0, 0>) }
>
> would rotate around the z-axis like usual.
>
> #include "transforms.inc"
>  object {My_Object Rotate_Around_Trans(z*90, <5, 0, 0>) }
>
> rotates around the z-axis where x=5.
>
> Macros are kinda like a subroutine.
> You define a macro by using the MACRO keyword
>
> #macro My_Macro (d, e, f)
>      #local g = d * 3;
>      sphere {<d, e, f>, g}
> #end
>
> #declare a = 1;
> #declare b = 2;
> #declare c = 3;
>
> My_Macro (a, b, c)
>
> The values plugged into the macro (a, b, and c) are copied over to the macro
> variables (e, f, and g) for use within the macro.
> The macro variable g is only defined within the macro - outside of the macro g
> is undefined.

Thanks a lot. :)
I make a macro named as Camera_rotation(a, b, c) and I am now able to rotate
camera. :)

Can we make a macro for a box? In which box is formed using 8 vertex?


Thanks
Gurwinder Singh Bains


Post a reply to this message

From: Bald Eagle
Subject: Re: Macro in POV-ray
Date: 19 Oct 2014 01:10:01
Message: <web.544346f35ae0f3ce5e7df57c0@news.povray.org>
> Can we make a macro for a box? In which box is formed using 8 vertex?

Boxes are traditionally just made with the BOX directive, specifying the two
opposing corners.
box {<0, 0, 0>, <1, 1, 1> pigment {Red}}

You can also get a box shape with a superquadratic ellipsoid:
superellipsoid {<0, 0> texture {pigment {Green} finish {phong 0.2}} }

Changing either zero to another value changes the shape, and you can get rounded
boxes, cylinders, spheres, etc.  It's a fun shape to use, but can be slow to
render.

There are also the Round Box and Wire Box shapes:
http://www.f-lohmueller.de/pov_tut/all_shapes/shapes330e.htm

Good Luck,

//==============================Bald Eagle====================================
cylinder{z,z*1.1,.65 pigment{cylindrical rotate x*90 color_map{[0 rgb<1,.2,0>]
[1 rgb xy]}}}#macro C(D,S,F,M)sin(radians(D+(F*90)+(i*S)))*A+M#end#local L=.9;
#local A=0.3125;#local i=0;#local T=.014;#macro
R(X,Y,D,S,M,N)cylinder{<X,Y,L>,<C(D,S,1,M),C(D,S,0,N),L>T}#end#macro
V(X,Y,Z,P,J,K,Q,U)cone{<X,Y,Z>P<J,K,Z>Q pigment{rgb U}}#end#while(i<8)#local
F=R(-0.243,.113,170,20,-.415,.069) #local
W=difference{R(-.172+(i/80),.328,250,5,-0.18,0.18)sphere {<-.14,.22,L>A/2.4}}
union{object{F}object{F scale-x*1}object{W}object{W scale-x*1}
cylinder{<.004,.095,L>,<-.007,-.18,L>,.1}pigment{Brown}}
cylinder{<-.008,-0.03,L>,<C(240,10,1,-.028),C(240,10,0,-.09),L>.014 pigment{rgb
1}}V(-.01,.095,L,.08,.003,.28,.021,1)V(-.001,.2,.85,0,.01,.26,.028,0)
V(.019,.23,.83,0,.026,.25,.01,xy)sphere{<.005,.25,.82>.002 pigment{rgb
1}}#declare i=i+1;#end
//=============================================================================


Post a reply to this message

From: Alain
Subject: Re: Macro in POV-ray
Date: 19 Oct 2014 18:51:25
Message: <5444406d@news.povray.org>


> Can we make a macro for a box? In which box is formed using 8 vertex?
>
>
> Thanks
> Gurwinder Singh Bains
>
>

While it can be made, it's much simpler, faster and less prone to errors 
to use the box primitive. The face of that box are parallel to the 
reference planes. If you want your box in another orientation, you just 
need to create is around the origin, rotate it as needed, and translate 
it to the desired location, or use the Rotate_Around_Trans macro.
It can also be done using the prism primitive using a 4 sided base. Good 
if the "box" you want faces are not parallel to each others.
You can also use a transform matrix if you want to shear your box.

Finaly, if you want to have non-flat faces, you can use an union of 8 
bicubic patches or a mesh.
A macro can automate the creation process for those.


Alain


Post a reply to this message

From: Bald Eagle
Subject: Re: Macro in POV-ray
Date: 19 Oct 2014 20:55:01
Message: <web.54445c965ae0f3ce5e7df57c0@news.povray.org>
Alain <kua### [at] videotronca> wrote:

> It can also be done using the prism primitive using a 4 sided base. Good
> if the "box" you want faces are not parallel to each others.

Good call.  I wasn't thinking about asymmetric instances.

> You can also use a transform matrix if you want to shear your box.

So many options. :D


> Finaly, if you want to have non-flat faces, you can use an union of 8
> bicubic patches or a mesh.
> A macro can automate the creation process for those.

True.  Almost limitless options with custom CSG objects.

There's also this -
http://www.f-lohmueller.de/pov_tut/a_geo/a_geo62e.htm

I may have to play around with the SuperCone object - that looks like it has
great potential for some things I've been thinking of trying.
http://www.f-lohmueller.de/pov_tut/all_shapes/shapes360e.htm


Post a reply to this message

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