POV-Ray : Newsgroups : povray.advanced-users : Macro in POV-ray : Re: Macro in POV-ray Server Time
16 May 2024 18:31:02 EDT (-0400)
  Re: Macro in POV-ray  
From: Bald Eagle
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

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