1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- This file copyright Persistence of Vision Raytracer Pty. Ltd. 2009-2011 -->
<html lang="en">
<head>
<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
<title>Reference Section 3</title>
<link rel="StyleSheet" href="povray37.css" type="text/css">
<link rel="shortcut icon" href="favicon.ico">
<!-- NOTE: In order to help users find information about POV-Ray using web -->
<!-- search engines, we ask that you *not* let them index documentation -->
<!-- mirrors because effectively, when searching, users will get hundreds of -->
<!-- results containing the same information! For this reason, these meta tags -->
<!-- below disable archiving of this page by search engines. -->
<meta name="robots" content="noarchive">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="expires" content="0">
</head>
<body>
<div class="Page">
<!-- NavPanel Begin -->
<div class="NavPanel">
<table class="NavTable">
<tr>
<td class="FixedPanelHeading"><a title="3.3" href="#r3_3">Scene Description Language</a></td>
</tr>
<tr>
<td><div class="divh2"><strong><a title="3.3.1" href="#r3_3_1">Language Basics</a></strong></div></td>
</tr>
<tr>
<td><div class="divh3"><a title="3.3.1.1" href="#r3_3_1_1">Notation and Basic Assumptions</a></div></td>
</tr>
<tr>
<td><div class="divh3"><a title="3.3.1.2" href="#r3_3_1_2">Keywords</a></div></td>
</tr>
<tr>
<td><div class="divh3"><a title="3.3.1.3" href="#r3_3_1_3">Identifiers</a></div></td>
</tr>
<tr>
<td><div class="divh3"><a title="3.3.1.4" href="#r3_3_1_4">Comments</a></div></td>
</tr>
<tr>
<td><div class="divh3"><a title="3.3.1.5" href="#r3_3_1_5">Numeric Expressions</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.1.5.1" href="#r3_3_1_5_1">Literals</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.1.5.2" href="#r3_3_1_5_2">Identifiers</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.1.5.3" href="#r3_3_1_5_3">Operators</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.1.5.4" href="#r3_3_1_5_4">Functions</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.1.5.5" href="#r3_3_1_5_5">Built-in Constants</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.1.5.6" href="#r3_3_1_5_6">Built-in Variables</a></div></td>
</tr>
<tr>
<td><div class="divh3"><a title="3.3.1.6" href="#r3_3_1_6">Vector Expressions</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.1.6.1" href="#r3_3_1_6_1">Literals</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.1.6.2" href="#r3_3_1_6_2">Identifiers</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.1.6.3" href="#r3_3_1_6_3">Operators</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.1.6.4" href="#r3_3_1_6_4">Operator Promotion</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.1.6.5" href="#r3_3_1_6_5">Functions</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.1.6.6" href="#r3_3_1_6_6">Built-in Constants</a></div></td>
</tr>
<tr>
<td><div class="divh3"><a title="3.3.1.7" href="#r3_3_1_7">Color Expressions</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.1.7.1" href="#r3_3_1_7_1">Color Vectors</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.1.7.2" href="#r3_3_1_7_2">sRGB Colors</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.1.7.3" href="#r3_3_1_7_3">Color Keywords</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.1.7.4" href="#r3_3_1_7_4">Color Identifiers</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.1.7.5" href="#r3_3_1_7_5">Color Operators</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.1.7.6" href="#r3_3_1_7_6">Common Color Pitfalls</a></div></td>
</tr>
<tr>
<td><div class="divh3"><a title="3.3.1.8" href="#r3_3_1_8">Function</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.1.8.1" href="#r3_3_1_8_1">Sum and Product functions</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.1.8.2" href="#r3_3_1_8_2">Functions and Macros</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.1.8.3" href="#r3_3_1_8_3">Declaring User-Defined Float Functions</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.1.8.4" href="#r3_3_1_8_4">Declaring User-Defined Vector Functions</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.1.8.5" href="#r3_3_1_8_5">Declaring User-Defined Color Functions</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.1.8.6" href="#r3_3_1_8_6">Internal Pre-Defined Functions</a></div></td>
</tr>
<tr>
<td><div class="divh3"><a title="3.3.1.9" href="#r3_3_1_9">Strings</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.1.9.1" href="#r3_3_1_9_1">String Literals</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.1.9.2" href="#r3_3_1_9_2">String Identifiers</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.1.9.3" href="#r3_3_1_9_3">String Relational Operators</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.1.9.4" href="#r3_3_1_9_4">String Functions</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.1.9.5" href="#r3_3_1_9_5">Built-in Variables</a></div></td>
</tr>
<tr>
<td><div class="divh3"><a title="3.3.1.10" href="#r3_3_1_10">Array</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.1.10.1" href="#r3_3_1_10_1">Declaring Arrays</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.1.10.2" href="#r3_3_1_10_2">Array Initializers</a></div></td>
</tr>
<tr>
<td><div class="divh3"><a title="3.3.1.11" href="#r3_3_1_11">Spline</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.1.11.1" href="#r3_3_1_11_1">Splines and Macros</a></div></td>
</tr>
<tr>
<td><div class="divh3"><a title="3.3.1.12" href="#r3_3_1_12">Transformations</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.1.12.1" href="#r3_3_1_12_1">Translate</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.1.12.2" href="#r3_3_1_12_2">Scale</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.1.12.3" href="#r3_3_1_12_3">Rotate</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.1.12.4" href="#r3_3_1_12_4">Matrix</a></div></td>
</tr>
<tr>
<td><div class="divh2"><strong><a title="3.3.2" href="#r3_3_2">Language Directives</a></strong></div></td>
</tr>
<tr>
<td><div class="divh3"><a title="3.3.2.1" href="#r3_3_2_1">Include Directive</a></div></td>
</tr>
<tr>
<td><div class="divh3"><a title="3.3.2.2" href="#r3_3_2_2">Declare and Local Directives</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.2.2.1" href="#r3_3_2_2_1">Declaring identifiers</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.2.2.2" href="#r3_3_2_2_2">declare vs. local</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.2.2.3" href="#r3_3_2_2_3">Identifier Name Collisions</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.2.2.4" href="#r3_3_2_2_4">Destroying Identifiers with undef</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.2.2.5" href="#r3_3_2_2_5">Deprecation Support</a></div></td>
</tr>
<tr>
<td><div class="divh3"><a title="3.3.2.3" href="#r3_3_2_3">File I/O Directives</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.2.3.1" href="#r3_3_2_3_1">The fopen Directive</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.2.3.2" href="#r3_3_2_3_2">The fclose Directive</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.2.3.3" href="#r3_3_2_3_3">The read Directive</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.2.3.4" href="#r3_3_2_3_4">The write Directive</a></div></td>
</tr>
<tr>
<td><div class="divh3"><a title="3.3.2.4" href="#r3_3_2_4">Default Directive</a></div></td>
</tr>
<tr>
<td><div class="divh3"><a title="3.3.2.5" href="#r3_3_2_5">Version Directive</a></div></td>
</tr>
<tr>
<td><div class="divh3"><a title="3.3.2.6" href="#r3_3_2_6">Conditional Directives</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.2.6.1" href="#r3_3_2_6_1">The if...else...end Directives</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.2.6.2" href="#r3_3_2_6_2">The ifdef and ifndef Directives</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.2.6.3" href="#r3_3_2_6_3">The for Directive</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.2.6.4" href="#r3_3_2_6_4">The switch, case, range and break Directives</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.2.6.5" href="#r3_3_2_6_5">The while...end Directive</a></div></td>
</tr>
<tr>
<td><div class="divh3"><a title="3.3.2.7" href="#r3_3_2_7">User Message Directives</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.2.7.1" href="#r3_3_2_7_1">Text Message Streams</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.2.7.2" href="#r3_3_2_7_2">Text Formatting</a></div></td>
</tr>
<tr>
<td><div class="divh3"><a title="3.3.2.8" href="#r3_3_2_8">User Defined Macros</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.2.8.1" href="#r3_3_2_8_1">The macro Directive</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.2.8.2" href="#r3_3_2_8_2">Invoking Macros</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.2.8.3" href="#r3_3_2_8_3">Are POV-Ray Macros a Function or a Macro?</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.2.8.4" href="#r3_3_2_8_4">Returning a Value Like a Function</a></div></td>
</tr>
<tr>
<td><div class="divh4"><a title="3.3.2.8.5" href="#r3_3_2_8_5">Returning Values Via Parameters</a></div></td>
</tr>
<tr>
<td><div class="divh1"> </div></td>
</tr>
<tr>
<td><div class="divh1"> </div></td>
</tr>
</table>
</div>
<!-- NavPanel End -->
<div class="Content">
<table class="HeaderFooter" width="100%">
<tr>
<td colspan=5 align="left" class="HeaderFooter">
POV-Ray for Unix <strong class="HeaderFooter">version 3.7</strong>
</td>
</tr>
<tr >
<td colspan=5>
<hr align="right" width="70%">
</td>
</tr>
<tr>
<td width="30%"></td>
<td class="NavBar"><a href="index.html" title="The Front Door">Home</a></td>
<td class="NavBar"><a href="u1_0.html" title="Unix Table of Contents">POV-Ray for Unix</a></td>
<td class="NavBar"><a href="t2_0.html" title="Tutorial Table of Contents">POV-Ray Tutorial</a></td>
<td class="NavBar"><a href="r3_0.html" title="Reference Table of Contents">POV-Ray Reference</a></td>
</tr>
</table>
<a name="r3_3"></a>
<div class="content-level-h2" contains="Scene Description Language" id="r3_3">
<h2>3.3 Scene Description Language</h2>
<p>This section describes the POV-Ray <em>scene description
language</em>. It is supposed to be used as a reference for looking up
things. It does not contain detailed explanations on how scenes are written
or how POV-Ray is used. It just explains all features, their syntax,
applications, limits, drawbacks, etc.</p>
<p>
The scene description language allows you to describe the world in a
readable and convenient way. Files are created in plain ASCII text using an
editor of your choice. The input file name is specified using the <code>
Input_File_Name</code>=<em>file</em> option or <code>+I</code><em>file</em>
switch. By default the files have the extension <code>.pov</code>. POV-Ray
reads the file, processes it by creating an internal model of the scene and
then renders the scene.</p>
<p>
The overall syntax of a scene is shown below. See <a href="r3_3.html#r3_3_1_1">Notation and Basic Assumptions</a>
for more information on syntax notation.</p>
<pre>
SCENE:
SCENE_ITEM...
SCENE_ITEM:
LANGUAGE_DIRECTIVE |
CAMERA |
LIGHT |
OBJECT |
ATMOSPHERIC_EFFECT |
GLOBAL_SETTINGS
</pre>
<p>In plain English, this means that a scene contains one or more scene items
and that a scene item may be any of the five items listed below it. The items
may appear in any order. None is a required item. In addition to the syntax
depicted above, a <em>LANGUAGE_DIRECTIVE</em> may also appear anywhere
embedded in other statements between any two tokens. There are some
restrictions on nesting directives also.</p>
<p>
For details on those five items see section <a href="r3_3.html#r3_3_2">Language Directives</a>, section <a href="r3_4.html#r3_4_5">Objects</a>, section <a href="r3_4.html#r3_4_2">Camera</a>, section <a href="r3_4.html#r3_4_3">Atomospheric Effects</a> and section <a href="r3_4.html#r3_4_1">Global Settings</a> for details.</p></div>
<a name="r3_3_1"></a>
<div class="content-level-h3" contains="Language Basics" id="r3_3_1">
<h3>3.3.1 Language Basics</h3>
<p>The POV-Ray language consists of identifiers, reserved keywords, floating point expressions, strings, special symbols and comments. The text of a POV-Ray scene file is free format. You may put statements on separate lines or on the same line as you desire. You may add blank lines, spaces or indentations as long as you do not split any keywords or identifiers.</p>
<p>See the following for more details:</p>
<ol>
<li><a href="r3_3.html#r3_3_1_2">Keywords</a></li>
<li><a href="r3_3.html#r3_3_1_3">Identifiers</a></li>
<li><a href="r3_3.html#r3_3_1_4">Comments</a></li>
<li><a href="r3_3.html#r3_3_1_5">Numeric Expressions</a></li>
<li><a href="r3_3.html#r3_3_1_6">Vector Expressions</a></li>
<li><a href="r3_3.html#r3_3_1_7">Color Expressions</a></li>
<li><a href="r3_3.html#r3_3_1_8">User-Defined Functions</a></li>
<li><a href="r3_3.html#r3_3_1_9">Strings</a></li>
<li><a href="r3_3.html#r3_3_1_10">Arrays</a></li>
<li><a href="r3_3.html#r3_3_1_11">Splines</a></li>
</ol></div>
<a name="r3_3_1_1"></a>
<div class="content-level-h4" contains="Notation and Basic Assumptions" id="r3_3_1_1">
<h4>3.3.1.1 Notation and Basic Assumptions</h4>
<p>Throughout the tutorial and reference books, a consistent notation is used to mark keywords of the scene description language, command line switches, INI file keywords and file names.</p>
<p><strong>For example:</strong></p>
<p>Scene description language keywords and command-line switches:</p>
<ul class="index">
<li><code>sphere</code>, <code>4.0 * sin(45.0)</code></li>
<li><code>+W640 +H480</code></li>
</ul>
<p>Syntax, optional syntax, multiple syntax, and zero or more syntax items allowed respectively:</p>
<ul class="index">
<li><code>SYNTAX_ITEM</code></li>
<li><code>[SYNTAX_ITEM]</code></li>
<li><code>SYNTAX_ITEM...</code></li>
<li><code>[SYNTAX_ITEM...]</code></li>
</ul>
<p>A float value or expression, and a vector value or expression:</p>
<ul class="index">
<li><code>Value_1</code></li>
<li><code><Value_1></code></li>
</ul>
<p>Alternatives are represented by a vertical bar between syntax items; exactly one of the listed items must be present:</p>
<ul class="index">
<li><code>ITEM1 | ITEM2 | ITEM3</code></li>
</ul>
<p>Arbitrary order is represented by an ampersand between syntax items:</p>
<ul class="index">
<li><code>ITEM1 & ITEM2 & ITEM3</code></li>
</ul>
<p>Fixed order is represented by simple juxtaposition of syntax items:</p>
<ul class="index">
<li><code>ITEM1 ITEM2 ITEM3</code></li>
</ul>
<p>The above notations can also appear in various combinations; parentheses are used to resolve ambiguities. For instance, the following notation would indicate that the optional items ITEM1 and ITEM2, as well as either ITEM3A or ITEM3B, may appear in any order:</p>
<ul class="index">
<li><code>[ITEM1] & [ITEM2] & (ITEM3A | ITEM3B)</code></li>
</ul>
<p class="Note"><strong>Note:</strong> The ampersand notation to denote arbitrary order is just being phased in; some syntax descriptions may still use juxtaposition, regardless of whether the order of items is irrelevant or not; please be aware that those are (or at least should be) exceptions.</p>
<p>Certain lists and arrays also require square braces as part of the language rather than the language description:</p>
<ul class="index">
<li><code>[ ITEM ]</code></li>
</ul>
<p class="Note"><strong>Note:</strong> POV-Ray is a command-line program on Unix and other text-based operating systems and is menu-driven on Windows and Macintosh platforms. Some of these operating systems use folders to store files while others use directories. Some separate the folders and sub-folders with a slash character (<code>/</code>), back-slash character (<code>\</code>), or others. </p>
<p>We have tried to make this documentation as generic as possible but sometimes we have to refer to folders, files, options etc. and there is noway to escape it. Here are some assumptions we make...</p><ol><li> You installed POV-Ray in the <code>C:\POVRAY36</code> directory. For MS-Dos this is probably true but for Unix it might be <code>/usr/povray3</code>, or for Windows it might be<code> C:\Program Files\POV-Ray for Windows v3.6</code>, for Mac it might be <code>MyHD:Apps:POV-Ray 36:</code>, or you may have used some other drive or directory. So if we tell you that Include files are stored in the <code>\povray36\include</code> directory, we assume you can translate that to something like<code>::POVRAY36:INCLUDE</code> or <code>C:\Program Files\POV-Ray for Windows v3.6\include</code> or whatever is appropriate for your platform, operating system and installation.<li> POV-Ray uses INI files and/or command-line switches (if available) to choose options in all versions, but Windows and Mac also use dialog boxes or menu choices to set options. We will describe options assuming you are using switches or INI files when describing what the options do. We have taken care to use the same terminology in designing menus and dialogs as we use in describing switches or INI keywords. See your version-specific documentation on menu and dialogs.<li> Some of you are reading this using a help-reader, built-in help,web-browser, formatted printout, or plain text file. We assume you know how to get around in which ever medium you are using. We will say See the chapter on <a href="t2_2.html#t2_2_8">Setting POV-Ray Options</a> we assume you can click, scroll, browse, flip pages or whatever to get there.</ol></div>
<a name="r3_3_1_2"></a>
<div class="content-level-h4" contains="Keywords" id="r3_3_1_2">
<h4>3.3.1.2 Keywords</h4>
<p>POV-Ray has a number of reserved keywords which are listed below.</p>
<table class="tablelist">
<tr>
<th colspan="3" align="left">a</th>
</tr>
<tr valign="top">
<td width="33%">
<code><a href="r3_4.html#r3_4_8_3">aa_level</a></code><br>
<code><a href="r3_4.html#r3_4_8_3">aa_threshold</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_4">abs</a></code><br>
<code><a href="r3_4.html#r3_4_8_2_1">absorption</a></code><br>
<code><a href="r3_4.html#r3_4_5_1_6">accuracy</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_4">acos</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_4">acosh</a></code><br>
<code><a href="r3_4.html#r3_4_4_1_5">adaptive</a></code><br>
<code><a href="r3_4.html#r3_4_1_1">adc_bailout</a></code> <em>global setting</em><br>
<code><a href="r3_4.html#r3_4_4_3_3_1">adc_bailout</a></code> <em>radiosity</em><br>
<code><a href="r3_4.html#r3_4_7_1_1">agate</a></code><br>
<code><a href="r3_4.html#r3_4_7_1_1">agate_turb</a></code><br>
<code><a href="r3_4.html#r3_4_6_3_3_1">albedo</a></code> <em>diffuse</em><br>
<code><a href="r3_4.html#r3_4_6_3_4_1">albedo</a></code> <em>phong</em><br>
</td>
<td width="33%">
<code><a href="r3_4.html#r3_4_6_3_4_2">albedo</a></code> <em>specular</em><br>
<code><a href="r3_4.html#r3_4_7_6_3">all</a></code><br>
<code><a href="r3_4.html#r3_4_5_1_6">all_intersections</a></code><br>
<code><a href="r3_4.html#r3_4_7_6_3">alpha</a></code><br>
<code><a href="r3_4.html#r3_4_7_3_2">altitude</a></code><br>
<code><a href="r3_4.html#r3_4_4_3_3_2">always_sample</a></code><br>
<code><a href="r3_4.html#r3_4_6_3_1">ambient</a></code><br>
<code><a href="r3_4.html#r3_4_1_2">ambient_light</a></code><br>
<code><a href="r3_4.html#r3_4_2_1">angle</a></code><br>
<code><a href="r3_4.html#r3_4_7_3_1">aoi</a></code><br>
<code><a href="r3_4.html#r3_4_2_3">aperture</a></code><br>
<code><a href="r3_3.html#r3_3_2_3_1">append</a></code><br>
<code><a href="r3_4.html#r3_4_3_5">arc_angle</a></code><br>
<code><a href="r3_4.html#r3_4_4_1_5">area_illumination</a></code><br>
</td>
<td width="33%">
<code><a href="r3_4.html#r3_4_4_1_5">area_light</a></code><br>
<code><a href="r3_3.html#r3_3_1_10">array</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_4">asc</a></code><br>
<code><a href="r3_4.html#r3_4_1_6">ascii</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_4">asin</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_4">asinh</a></code><br>
<code><a href="r3_4.html#r3_4_1_3">assumed_gamma</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_4">atan</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_4">atan2</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_4">atand</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_4">atanh</a></code><br>
<code><a href="r3_4.html#r3_4_4_4_9_1">autostop</a></code><br>
<code><a href="r3_4.html#r3_4_7_4_1">average</a></code><br>
</td>
</tr>
</table>
<table class="tablelist">
<tr valign="top">
<th colspan="3" align="left">b</th>
</tr>
<tr valign="top">
<td width="33%">
<code><a href="r3_4.html#r3_4_5_1_13">b_spline</a></code><br>
<code><a href="r3_4.html#r3_4_3_2">background</a></code><br>
<code><a href="r3_4.html#r3_4_5_1_8">bezier_spline</a></code><br>
<code><a href="r3_4.html#r3_4_5_2_1">bicubic_patch</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_4">bitwise_and</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_4">bitwise_or</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_4">bitwise_xor</a></code><br>
<code><a href="r3_4.html#r3_4_7_5_5_1">black_hole</a></code><br>
</td>
<td width="33%">
<code><a href="r3_4.html#r3_4_5_1_1">blob</a></code><br>
<code><a href="r3_3.html#r3_3_1_7_3">blue</a></code><br>
<code><a href="r3_4.html#r3_4_2_3">blur_samples</a></code><br>
<code><a href="r3_4.html#r3_4_2_3">bokeh</a></code><br>
<code><a href="r3_4.html#r3_4_5_5_2">bounded_by</a></code><br>
<code><a href="r3_4.html#r3_4_5_1_2">box</a></code><br>
<code><a href="r3_4.html#r3_4_7_1_2">boxed</a></code><br>
<code><a href="r3_4.html#r3_4_7_1_3">bozo</a></code><br>
</td>
<td width="33%">
<code><a href="r3_3.html#r3_3_2_6_4">break</a></code><br>
<code><a href="r3_4.html#r3_4_7_1_4">brick</a></code><br>
<code><a href="r3_4.html#r3_4_7_1_4">brick_size</a></code><br>
<code><a href="r3_4.html#r3_4_4_3_3_3">brightness</a></code><br>
<code><a href="r3_4.html#r3_4_6_3_3_2">brilliance</a></code><br>
<code><a href="r3_4.html#r3_4_6_2_3">bump_map</a></code><br>
<code><a href="r3_4.html#r3_4_6_2_3_2">bump_size</a></code><br>
<code><a href="r3_4.html#r3_4_7_1_5">bumps</a></code><br>
</td>
</tr>
</table>
<table class="tablelist">
<tr valign="top">
<th colspan="3" align="left">c</th>
</tr>
<tr valign="top">
<td width="33%">
<code><a href="r3_4.html#r3_4_2">camera</a></code><br>
<code><a href="r3_3.html#r3_3_2_6_4">case</a></code><br>
<code><a href="r3_4.html#r3_4_8_1_7">caustics</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_4">ceil</a></code><br>
<code><a href="r3_4.html#r3_4_7_2_1">cells</a></code><br>
<code><a href="r3_4.html#r3_4_1_6">charset</a></code><br>
<code><a href="r3_4.html#r3_4_7_2_2">checker</a></code><br>
<code><a href="r3_3.html#r3_3_1_9_4">chr</a></code><br>
<code><a href="r3_4.html#r3_4_4_1_5">circular</a></code><br>
<code><a href="r3_4.html#r3_4_5_5_1">clipped_by</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_6">clock</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_6">clock_delta</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_6">clock_on</a></code><br>
<code><a href="r3_4.html#r3_4_4_4_4">collect</a></code><br>
<code><a href="r3_3.html#r3_3_1_7">color</a></code><br>
</td>
<td width="33%">
<code><a href="r3_4.html#r3_4_6_1_2">color_map</a></code><br>
<code><a href="r3_3.html#r3_3_1_7">colour</a></code><br>
<code><a href="r3_4.html#r3_4_6_1_2">colour_map</a></code><br>
<code><a href="r3_4.html#r3_4_5_1_1">component</a></code><br>
<code><a href="r3_4.html#r3_4_5_4_2">composite</a></code><br>
<code><a href="r3_3.html#r3_3_1_9_4">concat</a></code><br>
<code><a href="r3_4.html#r3_4_5_1_3">cone</a></code><br>
<code><a href="r3_4.html#r3_4_2_3">confidence</a></code><br>
<code><a href="r3_4.html#r3_4_5_1_11">conic_sweep</a></code><br>
<code><a href="r3_4.html#r3_4_6_3_6">conserve_energy</a></code><br>
<code><a href="r3_4.html#r3_4_5_1_6">contained_by</a></code><br>
<code><a href="r3_4.html#r3_4_7_5">control0</a></code><br>
<code><a href="r3_4.html#r3_4_7_5">control1</a></code><br>
<code><a href="r3_4.html#r3_4_7_1_10">coords</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_4">cos</a></code><br>
</td>
<td width="33%">
<code><a href="r3_3.html#r3_3_1_5_4">cosh</a></code><br>
<code><a href="r3_4.html#r3_4_4_3_3_4">count</a></code><br>
<code><a href="r3_4.html#r3_4_7_2_3">crackle</a></code><br>
<code><a href="r3_4.html#r3_4_6_3_3_3">crand</a></code><br>
<code><a href="r3_4.html#r3_4_5_1_7">cube</a></code><br>
<code><a href="r3_4.html#r3_4_5_3_3">cubic</a></code> <em>object</em><br>
<code><a href="r3_4.html#r3_4_7_1_6">cubic</a></code> <em>pattern</em><br>
<code><a href="r3_4.html#r3_4_7_5_5_7">cubic</a></code> <em>warp</em><br>
<code><a href="r3_4.html#r3_4_5_1_8">cubic_spline</a></code><br>
<code><a href="r3_4.html#r3_4_7_5_3">cubic_wave</a></code><br>
<code><a href="r3_4.html#r3_4_6_10">cutaway_textures</a></code><br>
<code><a href="r3_4.html#r3_4_5_1_4">cylinder</a></code><br>
<code><a href="r3_4.html#r3_4_7_1_7">cylindrical</a></code><br>
</td>
</tr>
</table>
<table class="tablelist">
<tr valign="top">
<th colspan="3" align="left">d</th>
</tr>
<tr valign="top">
<td width="33%">
<code><a href="r3_3.html#r3_3_1_9_4">datetime</a></code><br>
<code><a href="r3_3.html#r3_3_2_7">debug</a></code><br>
<code><a href="r3_3.html#r3_3_2_2_1">declare</a></code><br>
<code><a href="r3_3.html#r3_3_2_4">default</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_4">defined</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_4">degrees</a></code><br>
<code><a href="r3_4.html#r3_4_8_4">density</a></code><br>
<code><a href="r3_4.html#r3_4_7_1_8">density_file</a></code><br>
</td>
<td width="33%">
<code><a href="r3_4.html#r3_4_8_4_3">density_map</a></code><br>
<code><a href="r3_4.html#r3_4_7_1_9">dents</a></code><br>
<code><a href="r3_3.html#r3_3_2_2_5">deprecated</a></code> <br>
<code><a href="r3_4.html#r3_4_7_1_8">df3</a></code><br>
<code><a href="r3_4.html#r3_4_5_4_4">difference</a></code><br>
<code><a href="r3_4.html#r3_4_6_3_3">diffuse</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_4">dimension_size</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_4">dimensions</a></code><br>
</td>
<td width="33%">
<code><a href="r3_4.html#r3_4_2_1_4">direction</a></code><br>
<code><a href="r3_4.html#r3_4_5_2_2">disc</a></code><br>
<code><a href="r3_4.html#r3_4_8_1_5">dispersion</a></code><br>
<code><a href="r3_4.html#r3_4_8_1_5">dispersion_samples</a></code><br>
<code><a href="r3_4.html#r3_4_7_5_5_7">dist_exp</a></code><br>
<code><a href="r3_4.html#r3_4_3_3">distance</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_4">div</a></code><br>
<code><a href="r3_4.html#r3_4_5_5_9">double_illuminate</a></code><br>
</td>
</tr>
</table>
<table class="tablelist">
<tr valign="top">
<th colspan="3" align="left">e</th>
</tr>
<tr valign="top">
<td width="33%">
<code><a href="r3_4.html#r3_4_8_2_3">eccentricity</a></code><br>
<code><a href="r3_3.html#r3_3_2_6_1">else</a></code><br>
<code><a href="r3_3.html#r3_3_2_6_1">elseif</a></code><br>
<code><a href="r3_4.html#r3_4_6_3_2">emission</a></code> <em>finish</em><br>
<code><a href="r3_4.html#r3_4_8_2_2">emission</a></code> <em>media</em><br>
</td>
<td width="33%">
<code><a href="r3_3.html#r3_3_2_6_1">end</a></code><br>
<code><a href="r3_3.html#r3_3_2_7">error</a></code><br>
<code><a href="r3_4.html#r3_4_4_3_3_5">error_bound</a></code><br>
<code><a href="r3_4.html#r3_4_5_1_6">evaluate</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_4">exp</a></code><br>
</td>
<td width="33%">
<code><a href="r3_4.html#r3_4_4_4_9_2">expand_thresholds</a></code><br>
<code><a href="r3_4.html#r3_4_6_3_5">exponent</a></code><br>
<code><a href="r3_4.html#r3_4_7_1_11">exterior</a></code><br>
<code><a href="r3_4.html#r3_4_8_2_3">extinction</a></code><br>
</td>
</tr>
</table>
<table class="tablelist">
<tr valign="top">
<th colspan="3" align="left">f</th>
</tr>
<tr valign="top">
<td width="33%">
<code><a href="r3_4.html#r3_4_5_2_4">face_indices</a></code><br>
<code><a href="r3_4.html#r3_4_7_1_10">facets</a></code><br>
<code><a href="r3_4.html#r3_4_8_1_6">fade_color</a></code><br>
<code><a href="r3_4.html#r3_4_8_1_6">fade_colour</a></code><br>
<code><a href="r3_4.html#r3_4_4_1_9">fade_distance</a></code><br>
<code><a href="r3_4.html#r3_4_4_1_9">fade_power</a></code><br>
<code><a href="r3_4.html#r3_4_4_1_2">falloff</a></code><br>
<code><a href="r3_4.html#r3_4_3_5">falloff_angle</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_5">false</a></code><br>
<code><a href="r3_3.html#r3_3_2_3">fclose</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_4">file_exists</a></code><br>
</td>
<td width="33%">
<code><a href="r3_3.html#r3_3_1_7_3">filter</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_6">final_clock</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_6">final_frame</a></code><br>
<code><a href="r3_4.html#r3_4_6_3">finish</a></code><br>
<code><a href="r3_4.html#r3_4_2_2_4">fisheye</a></code><br>
<code><a href="r3_4.html#r3_4_5_2_1">flatness</a></code><br>
<code><a href="r3_4.html#r3_4_7_5_5_2">flip</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_4">floor</a></code><br>
<code><a href="r3_4.html#r3_4_2_3">focal_point</a></code><br>
<code><a href="r3_4.html#r3_4_3_3">fog</a></code><br>
<code><a href="r3_4.html#r3_4_3_3">fog_alt</a></code><br>
</td>
<td width="33%">
<code><a href="r3_4.html#r3_4_3_3">fog_offset</a></code><br>
<code><a href="r3_4.html#r3_4_3_3">fog_type</a></code><br>
<code><a href="r3_3.html#r3_3_2_3_1">fopen</a></code><br>
<code><a href="r3_3.html#r3_3_2_6_3">for</a></code><br>
<code><a href="r3_4.html#r3_4_7_2_3">form</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_6">frame_number</a></code><br>
<code><a href="r3_4.html#r3_4_7_5_2">frequency</a></code><br>
<code><a href="r3_4.html#r3_4_6_3_5">fresnel</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_4">function</a></code><br>
</td>
</tr>
</table>
<table class="tablelist">
<tr valign="top">
<th colspan="3" align="left">g</th>
</tr>
<tr valign="top">
<td width="33%">
<code><a href="r3_4.html#r3_4_6_2_3">gamma</a></code> <em>bump maps</em><br>
<code><a href="r3_4.html#r3_4_5_1_5">gamma</a></code> <em>heightfield</em><br>
<code><a href="r3_4.html#r3_4_7_6_2">gamma</a></code> <em>image map</em><br>
<code><a href="r3_4.html#r3_4_7_4_2">gamma</a></code> <em>image pattern</em><br>
<code><a href="r3_4.html#r3_4_4_4_3">gather</a></code><br>
</td>
<td width="33%">
<code><a href="r3_4.html#r3_4_7_6_1">gif</a></code><br>
<code><a href="r3_4.html#r3_4_4_2">global_lights</a></code><br>
<code><a href="r3_4.html#r3_4_1">global_settings</a></code><br>
<code><a href="r3_4.html#r3_4_7_1_13">gradient</a></code><br>
<code><a href="r3_4.html#r3_4_7_1_14">granite</a></code><br>
</td>
<td width="33%">
<code><a href="r3_3.html#r3_3_1_7_5">gray</a></code><br>
<code><a href="r3_4.html#r3_4_4_3_3_6">gray_threshold</a></code><br>
<code><a href="r3_3.html#r3_3_1_7_3">green</a></code><br>
</td>
</tr>
</table>
<table class="tablelist">
<tr valign="top">
<th colspan="3" align="left">h</th>
</tr>
<tr valign="top">
<td width="33%">
<code><a href="r3_4.html#r3_4_5_1_5">height_field</a></code><br>
<code><a href="r3_4.html#r3_4_7_2_4">hexagon</a></code><br>
</td>
<td width="33%">
<code><a href="r3_4.html#r3_4_1_4">hf_gray_16</a></code><br>
<code><a href="r3_4.html#r3_4_5_1_1">hierarchy</a></code><br>
</td>
<td width="33%">
<code><a href="r3_4.html#r3_4_5_1_7">hypercomplex</a></code><br>
<code><a href="r3_4.html#r3_4_5_5_4">hollow</a></code><br>
</td>
</tr>
</table>
<table class="tablelist">
<tr valign="top">
<th colspan="3" align="left">i</th>
</tr>
<tr valign="top">
<td width="33%">
<code><a href="r3_3.html#r3_3_2_6_1">if</a></code><br>
<code><a href="r3_3.html#r3_3_2_6_2">ifdef</a></code><br>
<code><a href="r3_4.html#r3_4_7_6_1">iff</a></code><br>
<code><a href="r3_3.html#r3_3_2_6_2">ifndef</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_6">image_height</a></code><br>
<code><a href="r3_4.html#r3_4_7_6">image_map</a></code><br>
<code><a href="r3_4.html#r3_4_7_4_2">image_pattern</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_6">image_width</a></code><br>
<code><a href="r3_4.html#r3_4_4_3_4_1">importance</a></code><br>
</td>
<td width="33%">
<code><a href="r3_3.html#r3_3_2_1">include</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_6">initial_clock</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_6">initial_frame</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_6">input_file_name</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_4">inside</a></code><br>
<code><a href="r3_4.html#r3_4_5_2_3_1">inside_vector</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_4">int</a></code><br>
<code><a href="r3_4.html#r3_4_8_1">interior</a></code><br>
<code><a href="r3_4.html#r3_4_6_9">interior_texture</a></code><br>
</td>
<td width="33%">
<code><a href="r3_4.html#r3_4_9_1_7_9">internal</a></code><br>
<code><a href="r3_4.html#r3_4_7_7_3">interpolate</a></code><br>
<code><a href="r3_4.html#r3_4_5_4_3">intersection</a></code><br>
<code><a href="r3_4.html#r3_4_8_3">intervals</a></code><br>
<code><a href="r3_4.html#r3_4_5_5_5">inverse</a></code><br>
<code><a href="r3_4.html#r3_4_8_1_4">ior</a></code><br>
<code><a href="r3_4.html#r3_4_6_3_7">irid</a></code><br>
<code><a href="r3_4.html#r3_4_1_5">irid_wavelength</a></code><br>
<code><a href="r3_4.html#r3_4_5_1_6">isosurface</a></code><br>
</td>
</tr>
</table>
<table class="tablelist">
<tr valign="top">
<th colspan="3" align="left">j</th>
</tr>
<tr valign="top">
<td width="33%">
<code><a href="r3_4.html#r3_4_4_1_5">jitter</a></code><br>
<code><a href="r3_4.html#r3_4_7_6_1">jpeg</a></code><br>
</td>
<td width="33%">
<code><a href="r3_4.html#r3_4_7_1_11">julia</a></code><br>
<code><a href="r3_4.html#r3_4_5_1_7">julia_fractal</a></code><br>
</td>
<td width="33%">
</td>
</tr>
</table>
<table class="tablelist">
<tr valign="top">
<th colspan="3" align="left">l</th>
</tr>
<tr valign="top">
<td width="33%">
<code><a href="r3_4.html#r3_4_7_5_5_5">lambda</a></code><br>
<code><a href="r3_4.html#r3_4_5_1_8">lathe</a></code><br>
<code><a href="r3_4.html#r3_4_7_1_15">leopard</a></code><br>
<code><a href="r3_4.html#r3_4_4_2">light_group</a></code><br>
<code><a href="r3_4.html#r3_4_4_1">light_source</a></code><br>
</td>
<td width="33%">
<code><a href="r3_4.html#r3_4_5_1_8">linear_spline</a></code><br>
<code><a href="r3_4.html#r3_4_5_1_11">linear_sweep</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_4">ln</a></code><br>
<code><a href="r3_4.html#r3_4_4_3_4_5">load_file</a></code><br>
<code><a href="r3_3.html#r3_3_2_2">local</a></code><br>
</td>
<td width="33%">
<code><a href="r3_4.html#r3_4_2_1_1">location</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_4">log</a></code><br>
<code><a href="r3_4.html#r3_4_2_1_1">look_at</a></code><br>
<code><a href="r3_4.html#r3_4_4_1_7">looks_like</a></code><br>
<code><a href="r3_4.html#r3_4_4_3_3_7">low_error_factor</a></code><br>
</td>
</tr>
</table>
<table class="tablelist">
<tr valign="top">
<th colspan="3" align="left">m</th>
</tr>
<tr valign="top">
<td width="33%">
<code><a href="r3_3.html#r3_3_2_8_1">macro</a></code><br>
<code><a href="r3_4.html#r3_4_7_1_11">magnet</a></code><br>
<code><a href="r3_4.html#r3_4_7_5">major_radius</a></code><br>
<code><a href="r3_4.html#r3_4_7_1_11">mandel</a></code><br>
<code><a href="r3_4.html#r3_4_7_7_2">map_type</a></code><br>
<code><a href="r3_4.html#r3_4_7_1_16">marble</a></code><br>
<code><a href="r3_4.html#r3_4_5_5_3">material</a></code><br>
<code><a href="r3_4.html#r3_4_6_5_3">material_map</a></code><br>
<code><a href="r3_3.html#r3_3_1_12_4">matrix</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_4">max</a></code><br>
<code><a href="r3_4.html#r3_4_4_3_3_9">maximum_reuse</a></code><br>
</td>
<td width="33%">
<code><a href="r3_3.html#r3_3_1_6_5">max_extent</a></code><br>
<code><a href="r3_4.html#r3_4_5_1_6">max_gradient</a></code><br>
<code><a href="r3_4.html#r3_4_1_8">max_intersections</a></code><br>
<code><a href="r3_4.html#r3_4_5_1_7">max_iteration</a></code><br>
<code><a href="r3_4.html#r3_4_4_3_3_8">max_sample</a></code><br>
<code><a href="r3_4.html#r3_4_5_1_6">max_trace</a></code><br>
<code><a href="r3_4.html#r3_4_1_7">max_trace_level</a></code><br>
<code><a href="r3_4.html#r3_4_8">media</a></code><br>
<code><a href="r3_4.html#r3_4_4_1_11">media_attenuation</a></code><br>
<code><a href="r3_4.html#r3_4_4_1_10">media_interaction</a></code><br>
<code><a href="r3_4.html#r3_4_5_4_5">merge</a></code><br>
</td>
<td width="33%">
<code><a href="r3_4.html#r3_4_5_2_3">mesh</a></code><br>
<code><a href="r3_4.html#r3_4_5_2_4">mesh2</a></code><br>
<code><a href="r3_4.html#r3_4_6_3_4_3">metallic</a></code><br>
<code><a href="r3_4.html#r3_4_8_3">method</a></code><br>
<code><a href="r3_4.html#r3_4_7_2_3">metric</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_4">min</a></code><br>
<code><a href="r3_3.html#r3_3_1_6_5">min_extent</a></code><br>
<code><a href="r3_4.html#r3_4_4_3_3_10">minimum_reuse</a></code><br>
<code><a href="r3_4.html#r3_4_6_3_3_4">mm_per_unit</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_4">mod</a></code><br>
<code><a href="r3_4.html#r3_4_7_5">mortar</a></code><br>
</td>
</tr>
</table>
<table class="tablelist">
<tr valign="top">
<th colspan="3" align="left">n</th>
</tr>
<tr valign="top">
<td width="33%">
<code><a href="r3_3.html#r3_3_1_11">natural_spline</a></code><br>
<code><a href="r3_4.html#r3_4_4_3_3_11">nearest_count</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_5">no</a></code><br>
<code><a href="r3_4.html#r3_4_6_2_4">no_bump_scale</a></code><br>
<code><a href="r3_4.html#r3_4_5_5_7">no_image</a></code><br>
</td>
<td width="33%">
<code><a href="r3_4.html#r3_4_5_5_10">no_radiosity</a></code><br>
<code><a href="r3_4.html#r3_4_5_5_8">no_reflection</a></code><br>
<code><a href="r3_4.html#r3_4_5_5_6">no_shadow</a></code><br>
<code><a href="r3_4.html#r3_4_7_5_4">noise_generator</a></code><br>
<code><a href="r3_4.html#r3_4_6_2">normal</a></code><br>
</td>
<td width="33%">
<code><a href="r3_4.html#r3_4_5_2_4">normal_indices</a></code><br>
<code><a href="r3_4.html#r3_4_6_2_1">normal_map</a></code><br>
<code><a href="r3_4.html#r3_4_5_2_4">normal_vectors</a></code><br>
<code><a href="r3_3.html#r3_3_1_9_4">now</a></code><br>
<code><a href="r3_4.html#r3_4_1_10">number_of_waves</a></code><br>
</td>
</tr>
</table>
<table class="tablelist">
<tr valign="top">
<th colspan="3" align="left">o</th>
</tr>
<tr valign="top">
<td width="33%">
<code><a href="r3_4.html#r3_4_5">object</a></code><br>
<code><a href="r3_4.html#r3_4_7_5_5_4">octaves</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_5">off</a></code><br>
<code><a href="r3_4.html#r3_4_7_5_5_2">offset</a></code><br>
<code><a href="r3_4.html#r3_4_7_5_5_6">omega</a></code><br>
</td>
<td width="33%">
<code><a href="r3_4.html#r3_4_2_2_6">omnimax</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_5">on</a></code><br>
<code><a href="r3_4.html#r3_4_7_7_1">once</a></code><br>
<code><a href="r3_4.html#r3_4_7_1_17">onion</a></code><br>
<code><a href="r3_4.html#r3_4_8_1">open</a></code><br>
</td>
<td width="33%">
<code><a href="r3_4.html#r3_4_4_1_5">orient</a></code><br>
<code><a href="r3_4.html#r3_4_7_5_5_7">orientation</a></code><br>
<code><a href="r3_4.html#r3_4_2_2_2">orthographic</a></code><br>
<code><a href="r3_4.html#r3_4_5_1_9">ovus</a></code><br>
</td>
</tr>
</table>
<table class="tablelist">
<tr valign="top">
<th colspan="3" align="left">p</th>
</tr>
<tr valign="top">
<td width="33%">
<code><a href="r3_4.html#r3_4_2_2_7">panoramic</a></code><br>
<code><a href="r3_4.html#r3_4_4_1_4">parallel</a></code><br>
<code><a href="r3_4.html#r3_4_5_1_10">parametric</a></code><br>
<code><a href="r3_4.html#r3_4_4_4_4">pass_through</a></code><br>
<code><a href="r3_4.html#r3_4_7">pattern</a></code><br>
<code><a href="r3_4.html#r3_4_7_1_18">pavement</a></code><br>
<code><a href="r3_4.html#r3_4_2_2_1">perspective</a></code><br>
<code><a href="r3_4.html#r3_4_7_6_1">pgm</a></code><br>
<code><a href="r3_4.html#r3_4_7_5_2">phase</a></code><br>
<code><a href="r3_4.html#r3_4_6_3_4_1">phong</a></code><br>
<code><a href="r3_4.html#r3_4_6_3_4_1">phong_size</a></code><br>
<code><a href="r3_4.html#r3_4_4_4">photons</a></code><br>
</td>
<td width="33%">
<code><a href="r3_3.html#r3_3_1_5_5">pi</a></code><br>
<code><a href="r3_4.html#r3_4_6_1">pigment</a></code><br>
<code><a href="r3_4.html#r3_4_6_1_3">pigment_map</a></code><br>
<code><a href="r3_4.html#r3_4_7_1_19">pigment_pattern</a></code><br>
<code><a href="r3_4.html#r3_4_7_1_20">planar</a></code><br>
<code><a href="r3_4.html#r3_4_5_3_1">plane</a></code><br>
<code><a href="r3_4.html#r3_4_7_6_1">png</a></code><br>
<code><a href="r3_4.html#r3_4_4_1_2">point_at</a></code><br>
<code><a href="r3_4.html#r3_4_5_3_2">poly</a></code><br>
<code><a href="r3_4.html#r3_4_5_3_5">polynomial</a></code><br>
<code><a href="r3_4.html#r3_4_7_5_3">poly_wave</a></code><br>
<code><a href="r3_4.html#r3_4_5_2_5">polygon</a></code><br>
</td>
<td width="33%">
<code><a href="r3_4.html#r3_4_5_1_5">pot</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_4">pow</a></code><br>
<code><a href="r3_4.html#r3_4_7_6_1">ppm</a></code><br>
<code><a href="r3_4.html#r3_4_5_1_7">precision</a></code><br>
<code><a href="r3_4.html#r3_4_5_1_10">precompute</a></code><br>
<code><a href="r3_4.html#r3_4_7_6_4">premultiplied</a></code><br>
<code><a href="r3_4.html#r3_4_4_3_3_12">pretrace_end</a></code><br>
<code><a href="r3_4.html#r3_4_4_3_3_12">pretrace_start</a></code><br>
<code><a href="r3_4.html#r3_4_5_1_11">prism</a></code><br>
<code><a href="r3_3.html#r3_3_1_8_1">prod</a></code><br>
<code><a href="r3_4.html#r3_4_4_1_8">projected_through</a></code><br>
<code><a href="r3_4.html#r3_4_5_1_7">pwr</a></code><br>
</td>
</tr>
</table>
<table class="tablelist">
<tr valign="top">
<th colspan="3" align="left">q</th>
</tr>
<tr valign="top">
<td width="33%">
<code><a href="r3_4.html#r3_4_5_1_8">quadratic_spline</a></code><br>
<code><a href="r3_4.html#r3_4_5_3_6">quadric</a></code><br>
<code><a href="r3_4.html#r3_4_5_3_4">quartic</a></code><br>
</td>
<td width="33%">
<code><a href="r3_4.html#r3_4_5_1_7">quaternion</a></code><br>
<code><a href="r3_4.html#r3_4_6_1_5">quick_color</a></code><br>
<code><a href="r3_4.html#r3_4_6_1_5">quick_colour</a></code><br>
</td>
<td width="33%">
<code><a href="r3_4.html#r3_4_7_1_21">quilted</a></code><br>
</td>
</tr>
</table>
<table class="tablelist">
<tr valign="top">
<th colspan="3" align="left">r</th>
</tr>
<tr valign="top">
<td width="33%">
<code><a href="r3_4.html#r3_4_7_1_22">radial</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_4">radians</a></code><br>
<code><a href="r3_4.html#r3_4_4_3">radiosity</a></code><br>
<code><a href="r3_4.html#r3_4_4_1_2">radius</a></code><br>
<code><a href="r3_4.html#r3_4_3_5">rainbow</a></code><br>
<code><a href="r3_4.html#r3_4_7_5_3">ramp_wave</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_4">rand</a></code><br>
<code><a href="r3_3.html#r3_3_2_6_4">range</a></code><br>
<code><a href="r3_4.html#r3_4_8_3">ratio</a></code><br>
</td>
<td width="33%">
<code><a href="r3_3.html#r3_3_2_3">read</a></code><br>
<code><a href="r3_4.html#r3_4_5_1_7">reciprocal</a></code><br>
<code><a href="r3_4.html#r3_4_4_3_3_13">recursion_limit</a></code><br>
<code><a href="r3_3.html#r3_3_1_7_3">red</a></code><br>
<code><a href="r3_4.html#r3_4_6_3_5">reflection</a></code><br>
<code><a href="r3_4.html#r3_4_6_3_5">reflection_exponent</a></code><br>
<code><a href="r3_4.html#r3_4_8_1_4">refraction</a></code><br>
<code><a href="r3_3.html#r3_3_2_7_1">render</a></code><br>
<code><a href="r3_4.html#r3_4_7_5_5_2">repeat</a></code><br>
</td>
<td width="33%">
<code><a href="r3_3.html#r3_3_1_7_1">rgb</a></code><br>
<code><a href="r3_3.html#r3_3_1_7_1">rgbf</a></code><br>
<code><a href="r3_3.html#r3_3_1_7_1">rgbft</a></code><br>
<code><a href="r3_3.html#r3_3_1_7_1">rgbt</a></code><br>
<code><a href="r3_4.html#r3_4_2_1_5">right</a></code><br>
<code><a href="r3_4.html#r3_4_7_1_23">ripples</a></code><br>
<code><a href="r3_3.html#r3_3_1_12_3">rotate</a></code><br>
<code><a href="r3_4.html#r3_4_6_3_4_2">roughness</a></code><br>
</td>
</tr>
</table>
<table class="tablelist">
<tr valign="top">
<th colspan="3" align="left">s</th>
</tr>
<tr valign="top">
<td width="33%">
<code><a href="r3_4.html#r3_4_8_3">samples</a></code><br>
<code><a href="r3_4.html#r3_4_4_3_4_5">save_file</a></code><br>
<code><a href="r3_3.html#r3_3_1_12_2">scale</a></code><br>
<code><a href="r3_4.html#r3_4_7_5_3">scallop_wave</a></code><br>
<code><a href="r3_4.html#r3_4_8_2_3">scattering</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_4">seed</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_4">select</a></code><br>
<code><a href="r3_4.html#r3_4_4_1_6">shadowless</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_4">sin</a></code><br>
<code><a href="r3_4.html#r3_4_7_5_3">sine_wave</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_4">sinh</a></code><br>
<code><a href="r3_3.html#r3_3_2_3_4">sint8</a></code><br>
<code><a href="r3_3.html#r3_3_2_3_4">sint16be</a></code><br>
<code><a href="r3_3.html#r3_3_2_3_4">sint16le</a></code><br>
<code><a href="r3_3.html#r3_3_2_3_4">sint32be</a></code><br>
<code><a href="r3_3.html#r3_3_2_3_4">sint32le</a></code><br>
<code><a href="r3_4.html#r3_4_7_1_10">size</a></code><br>
<code><a href="r3_4.html#r3_4_2_1_2">sky</a></code><br>
<code><a href="r3_4.html#r3_4_3_4">sky_sphere</a></code><br>
<code><a href="r3_4.html#r3_4_5_1_7">slice</a></code><br>
<code><a href="r3_4.html#r3_4_7_3_2">slope</a></code><br>
<code><a href="r3_4.html#r3_4_6_2_2">slope_map</a></code><br>
</td>
<td width="33%">
<code><a href="r3_4.html#r3_4_5_1_5">smooth</a></code><br>
<code><a href="r3_4.html#r3_4_5_2_7">smooth_triangle</a></code><br>
<code><a href="r3_4.html#r3_4_7_2_3">solid</a></code><br>
<code><a href="r3_4.html#r3_4_5_1_15">sor</a></code><br>
<code><a href="r3_4.html#r3_4_4_4_3">spacing</a></code><br>
<code><a href="r3_4.html#r3_4_6_3_4_2">specular</a></code><br>
<code><a href="r3_4.html#r3_4_5_1_12">sphere</a></code><br>
<code><a href="r3_4.html#r3_4_5_1_13">sphere_sweep</a></code><br>
<code><a href="r3_4.html#r3_4_7_1_24">spherical</a></code><br>
<code><a href="r3_4.html#r3_4_7_1_25">spiral1</a></code><br>
<code><a href="r3_4.html#r3_4_7_1_26">spiral2</a></code><br>
<code><a href="r3_3.html#r3_3_1_11">spline</a></code><br>
<code><a href="r3_4.html#r3_4_5_4_2_1">split_union</a></code><br>
<code><a href="r3_4.html#r3_4_4_1_2">spotlight</a></code><br>
<code><a href="r3_4.html#r3_4_7_1_27">spotted</a></code><br>
<code><a href="r3_4.html#r3_4_5_1_7">sqr</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_4">sqrt</a></code><br>
<code><a href="r3_4.html#r3_4_7_2_6">square</a></code><br>
<code><a href="r3_4.html#r3_4_6_2_3">srgb</a></code> <em>bump maps</em><br>
<code><a href="r3_3.html#r3_3_1_7_2">srgb</a></code> <em>color literals</em><br>
<code><a href="r3_4.html#r3_4_5_1_5">srgb</a></code> <em>heightfield</em><br>
</td>
<td width="33%">
<code><a href="r3_4.html#r3_4_7_6_2">srgb</a></code> <em>image maps</em><br>
<code><a href="r3_4.html#r3_4_7_4_2">srgb</a></code> <em>image pattern</em><br>
<code><a href="r3_3.html#r3_3_1_7_2">srgbf</a></code><br>
<code><a href="r3_3.html#r3_3_1_7_2">srgbt</a></code><br>
<code><a href="r3_3.html#r3_3_1_7_2">srgbft</a></code><br>
<code><a href="r3_3.html#r3_3_2_7_1">statistics</a></code><br>
<code><a href="r3_3.html#r3_3_1_9_4">str</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_4">strcmp</a></code><br>
<code><a href="r3_4.html#r3_4_5_1_1">strength</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_4">strlen</a></code><br>
<code><a href="r3_3.html#r3_3_1_9_4">strlwr</a></code><br>
<code><a href="r3_3.html#r3_3_1_9_4">strupr</a></code><br>
<code><a href="r3_4.html#r3_4_5_5_11">sturm</a></code><br>
<code><a href="r3_3.html#r3_3_1_9_4">substr</a></code><br>
<code><a href="r3_4.html#r3_4_6_3_3_4">subsurface</a></code><br>
<code><a href="r3_3.html#r3_3_1_8_1">sum</a></code><br>
<code><a href="r3_4.html#r3_4_5_1_14">superellipsoid</a></code><br>
<code><a href="r3_3.html#r3_3_2_6_4">switch</a></code><br>
<code><a href="r3_4.html#r3_4_7_6_1">sys</a></code><br>
</td>
</tr>
</table>
<table class="tablelist">
<tr valign="top">
<th colspan="3" align="left">t</th>
</tr>
<tr valign="top">
<td width="33%">
<code><a href="r3_3.html#r3_3_1_6_6">t</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_4">tan</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_4">tanh</a></code><br>
<code><a href="r3_4.html#r3_4_4_4_4">target</a></code><br>
<code><a href="r3_4.html#r3_4_5_1_16">text</a></code><br>
<code><a href="r3_4.html#r3_4_6">texture</a></code><br>
<code><a href="r3_4.html#r3_4_6_5">texture_list</a></code><br>
<code><a href="r3_4.html#r3_4_6_5_1">texture_map</a></code><br>
<code><a href="r3_4.html#r3_4_7_6_1">tga</a></code><br>
<code><a href="r3_4.html#r3_4_6_3_7">thickness</a></code><br>
<code><a href="r3_4.html#r3_4_5_1_1">threshold</a></code><br>
</td>
<td width="33%">
<code><a href="r3_4.html#r3_4_7_6_1">tiff</a></code><br>
<code><a href="r3_4.html#r3_4_4_1_2">tightness</a></code><br>
<code><a href="r3_4.html#r3_4_6_5_2">tile2</a></code><br>
<code><a href="r3_4.html#r3_4_6_5_2">tiles</a></code><br>
<code><a href="r3_4.html#r3_4_7_1_28">tiling</a></code><br>
<code><a href="r3_4.html#r3_4_5_1_13">tolerance</a></code><br>
<code><a href="r3_4.html#r3_4_7_5_5_7">toroidal</a></code><br>
<code><a href="r3_4.html#r3_4_5_1_17">torus</a></code><br>
<code><a href="r3_3.html#r3_3_1_6_5">trace</a></code><br>
<code><a href="r3_3.html#r3_3_1_12">transform</a></code><br>
<code><a href="r3_3.html#r3_3_1_12_1">translate</a></code><br>
</td>
<td width="33%">
<code><a href="r3_4.html#r3_4_6_3_3_4">translucency</a></code><br>
<code><a href="r3_3.html#r3_3_1_7_3">transmit</a></code><br>
<code><a href="r3_4.html#r3_4_5_2_6">triangle</a></code><br>
<code><a href="r3_4.html#r3_4_7_5_3">triangle_wave</a></code><br>
<code><a href="r3_4.html#r3_4_7_2_7">triangular</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_5">true</a></code><br>
<code><a href="r3_4.html#r3_4_5_1_16">ttf</a></code><br>
<code><a href="r3_4.html#r3_4_3_3">turb_depth</a></code><br>
<code><a href="r3_4.html#r3_4_7_5_5_9">turbulence</a></code><br>
<code><a href="r3_4.html#r3_4_5_2_1">type</a></code><br>
</td>
</tr>
</table>
<table class="tablelist">
<tr valign="top">
<th colspan="3" align="left">u</th>
</tr>
<tr valign="top">
<td width="33%">
<code><a href="r3_3.html#r3_3_1_6_6">u</a></code><br>
<code><a href="r3_3.html#r3_3_2_3_4">uint8</a></code><br>
<code><a href="r3_3.html#r3_3_2_3_4">uint16be</a></code><br>
<code><a href="r3_3.html#r3_3_2_3_4">uint16le</a></code><br>
<code><a href="r3_4.html#r3_4_5_2_1">u_steps</a></code><br>
<code><a href="r3_4.html#r3_4_2_2_5">ultra_wide_angle</a></code><br>
</td>
<td width="33%">
<code><a href="r3_3.html#r3_3_2_2_4">undef</a></code><br>
<code><a href="r3_4.html#r3_4_5_4_2">union</a></code><br>
<code><a href="r3_4.html#r3_4_2_1_5">up</a></code><br>
<code><a href="r3_4.html#r3_4_7_4_2">use_alpha</a></code><br>
<code><a href="r3_4.html#r3_4_6_2_3_3">use_color</a></code><br>
<code><a href="r3_4.html#r3_4_6_2_3_3">use_colour</a></code><br>
</td>
<td width="33%">
<code><a href="r3_4.html#r3_4_6_2_3_3">use_index</a></code><br>
<code><a href="r3_4.html#r3_4_1_6">utf8</a></code><br>
<code><a href="r3_4.html#r3_4_5_2_4">uv_indices</a></code><br>
<code><a href="r3_4.html#r3_4_6_7">uv_mapping</a></code><br>
<code><a href="r3_4.html#r3_4_6_7_2">uv_vectors</a></code><br>
</td>
</tr>
</table>
<table class="tablelist">
<tr valign="top">
<th colspan="3" align="left">v</th>
</tr>
<tr valign="top">
<td width="33%">
<code><a href="r3_3.html#r3_3_1_6_6">v</a></code><br>
<code><a href="r3_4.html#r3_4_5_2_1">v_steps</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_4">val</a></code><br>
<code><a href="r3_4.html#r3_4_2_3">variance</a></code><br>
<code><a href="r3_3.html#r3_3_1_6_5">vaxis_rotate</a></code><br>
</td>
<td width="33%">
<code><a href="r3_3.html#r3_3_1_6_5">vcross</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_4">vdot</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_6">version</a></code><br>
<code><a href="r3_4.html#r3_4_5_2_4">vertex_vectors</a></code><br>
<code><a href="r3_3.html#r3_3_1_5_4">vlength</a></code><br>
</td>
<td width="33%">
<code><a href="r3_3.html#r3_3_1_6_5">vnormalize</a></code><br>
<code><a href="r3_3.html#r3_3_1_6_5">vrotate</a></code><br>
<code><a href="r3_3.html#r3_3_1_9_4">vstr</a></code><br>
<code><a href="r3_3.html#r3_3_1_6_5">vturbulence</a></code><br>
</td>
</tr>
</table>
<table class="tablelist">
<tr valign="top">
<th colspan="3" align="left">w</th>
</tr>
<tr valign="top">
<td width="33%">
<code><a href="r3_3.html#r3_3_2_7_1">warning</a></code><br>
<code><a href="r3_4.html#r3_4_7_5_5">warp</a></code><br>
<code><a href="r3_4.html#r3_4_5_1_5">water_level</a></code><br>
</td>
<td width="33%">
<code><a href="r3_4.html#r3_4_7_1_29">waves</a></code><br>
<code><a href="r3_3.html#r3_3_2_6_5">while</a></code><br>
<code><a href="r3_4.html#r3_4_3_5">width</a></code><br>
</td>
<td width="33%">
<code><a href="r3_4.html#r3_4_7_1_30">wood</a></code><br>
<code><a href="r3_4.html#r3_4_7_1_31">wrinkles</a></code><br>
<code><a href="r3_3.html#r3_3_2_3_4">write</a></code><br>
</td>
</tr>
</table>
<table class="tablelist">
<tr valign="top">
<th colspan="3" align="left">x</th>
</tr>
<tr valign="top">
<td width="33%">
<code><a href="r3_3.html#r3_3_1_6_6">x</a></code><br>
</td>
<td width="33%">
</td>
<td width="33%">
</td>
</tr>
</table>
<table class="tablelist">
<tr valign="top">
<th colspan="3" align="left">y</th>
</tr>
<tr valign="top">
<td width="33%">
<code><a href="r3_3.html#r3_3_1_6_6">y</a></code><br>
</td>
<td width="33%">
<code><a href="r3_3.html#r3_3_1_5_5">yes</a></code><br>
</td>
<td width="33%">
</td>
</tr>
</table>
<table class="tablelist" summary="All reserved keywords">
<tr valign="top">
<th colspan="3" align="left">z</th>
</tr>
<tr valign="top">
<td width="33%">
<code><a href="r3_3.html#r3_3_1_6_6">z</a></code><br>
</td>
<td width="33%">
</td>
<td width="33%">
</td>
</tr>
</table></div>
<a name="r3_3_1_3"></a>
<div class="content-level-h4" contains="Identifiers" id="r3_3_1_3">
<h4>3.3.1.3 Identifiers</h4>
<p>POV-Ray allows you to define identifiers for later use in the scene file.
An identifier may be 1 to 40 characters long. It may consist of upper and
lower case letters, the digits 0 through 9 or an underscore character
("_"). The first character must be an alphabetic character. The
declaration of identifiers is covered later.</p>
<p>All <a href="r3_3.html#r3_3_1_2">keywords</a> (reserved words) are fully lower case. Therefore it is recommended that
your identifiers contain at least one upper case character so it is sure to
avoid conflict with reserved words.</p></div>
<a name="r3_3_1_4"></a>
<div class="content-level-h4" contains="Comments" id="r3_3_1_4">
<h4>3.3.1.4 Comments</h4>
<p>Comments are text in the scene file included to make the scene file easier
to read or understand. They are ignored by the ray-tracer and are there for
your information. There are two types of comments in POV-Ray.</p>
<p>
Two slashes are used for single line comments. Anything on a line after a
double slash (<code>//</code>) is ignored by the ray-tracer. For example:</p>
<pre>
// This line is ignored
</pre>
<p>You can have scene file information on the line in front of the comment as
in:</p>
<pre>
object { FooBar } // this is an object
</pre>
<p>The other type of comment is used for multiple lines. It starts with
"<code>/*</code>" and ends with "<code>*/</code>".
Everything in-between is ignored. For example:</p>
<pre>
/* These lines
are ignored
by the
ray-tracer */
</pre>
<p>This can be useful if you want to temporarily remove elements from a scene
file. <code>/*</code> ... <code>*/</code> comments can <em>comment out</em>
lines containing other <code>//</code> comments and thus can be used to
temporarily or permanently comment out parts of a scene. <code> /*</code> ...
<code>*/</code> comments can be nested, the following is legal:</p>
<pre>
/* This is a comment
// This too
/* This also */
*/
</pre>
<p>Use comments liberally and generously. Well used, they really improve the
readability of scene files.</p></div>
<a name="r3_3_1_5"></a>
<div class="content-level-h4" contains="Numeric Expressions" id="r3_3_1_5">
<h4>3.3.1.5 Numeric Expressions</h4>
<p>Many parts of the POV-Ray language require you to specify one or more
floating point numbers. A floating point number is a number with a decimal
point. Floats may be specified using literals, identifiers or functions which
return float values. You may also create very complex float expressions from
combinations of any of these using various familiar operators.</p>
<p>
Where POV-Ray needs an integer value it allows you to specify a float value
and it truncates it to an integer. When POV-Ray needs a logical or boolean
value it interprets any non-zero float as true and zero as false. Because
float comparisons are subject to rounding errors POV-Ray accepts values
extremely close to zero as being false when doing boolean functions.
Typically values whose absolute values are less than a preset value <em>
epsilon</em> are considered false for logical expressions. The value of <em>
epsilon</em> is system dependent but is generally about 1.0e-10. Two floats
<em>a</em> and <em>b</em> are considered to be equal if <em>abs(a-b) <
epsilon.</em></p>
<p>
The full syntax for float expressions is given below. Detailed explanations
are given in the following sub-sections.</p>
<pre>
FLOAT:
NUMERIC_TERM [SIGN NUMERIC_TERM]...
SIGN:
+ | -
NUMERIC_TERM:
NUMERIC_FACTOR [MULT NUMERIC_FACTOR]...
MULT:
* | /
NUMERIC_FACTOR:
FLOAT_LITERAL |
FLOAT_IDENTIFIER |
SIGN NUMERIC_FACTOR |
FLOAT_FUNCTION |
FLOAT_BUILT_IN_IDENT |
( FULL_EXPRESSION ) |
! NUMERIC_FACTOR |
VECTOR DECIMAL_POINT DOT_ITEM |
FLOAT_FUNCTION_INVOCATION
FLOAT_LITERAL:
MANTISSA [EXP [SIGN] DIGIT...]
MANTISSA:
DIGIT... [DECIMAL_POINT [DIGIT...]] |
DECIMAL_POINT DIGIT...
DIGIT:
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
DECIMAL_POINT:
.
EXP:
e | E
DOT_ITEM:
x | y | z | t | u | v | red | green | blue | filter |
transmit | gray
FLOAT_FUNCTION:
abs( FLOAT ) | acos( FLOAT ) | acosh( FLOAT ) | asc( STRING ) |
asin( FLOAT ) | asinh( FLOAT ) | atan( FLOAT) | atanh( FLOAT) |
atan2( FLOAT , FLOAT ) | bitwise_and( FLOAT, FLOAT, ...) |
bitwise_or (FLOAT, FLOAT, ...) | bitwise_xor ( FLOAT, FLOAT, ...) |
ceil( FLOAT ) | cos( FLOAT ) | cosh( FLOAT ) | defined(IDENTIFIER ) |
degrees( FLOAT ) | dimensions( ARRAY_IDENTIFIER ) |
dimension_size( ARRAY_IDENTIFIER , FLOAT ) |
div( FLOAT , FLOAT ) | exp( FLOAT ) | file_exists( STRING ) |
floor( FLOAT ) | int( FLOAT ) | ln(Float | log( FLOAT ) |
max( FLOAT , FLOAT, ... ) | min( FLOAT , FLOAT, ... ) |
mod( FLOAT , FLOAT ) | pow( FLOAT , FLOAT ) |
radians( FLOAT ) | rand( FLOAT ) | seed( FLOAT ) |
select( FLOAT, FLOAT, FLOAT [,FLOAT]) | sin( FLOAT ) |
sinh( FLOAT ) | sqrt( FLOAT ) | strcmp( STRING , STRING ) |
strlen( STRING ) | tan( FLOAT ) | tanh( FLOAT ) |
val( STRING ) | vdot( VECTOR , VECTOR ) | vlength( VECTOR ) |
FLOAT_BUILT_IN_IDENT:
clock | clock_delta | clock_on | false | final_clock |
final_frame | frame_number | image_height | image_width |
initial_clock | initial_frame | no | off | on | pi | true |
version | yes
FULL_EXPRESSION:
FLOAT |
LOGICAL_EXPRESSION [? FULL_EXPRESSION : FULL_EXPRESSION]
LOGICAL_EXPRESSION:
REL_TERM [LOGICAL_OPERATOR REL_TERM]...
LOGICAL_OPERATOR:
& | | (note: this means an ampersand or a
vertical bar is a logical operator)
REL_TERM:
FLOAT [REL_OPERATOR FLOAT]... |
STRING REL_OPERATOR STRING
REL_OPERATOR:
< | <= | = | >= | > | !=
INT:
FLOAT (note: any syntax which requires a
integer INT will accept a FLOAT
and it will be truncated to an
integer internally by POV-Ray).
</pre>
<p class="Note"><strong>Note:</strong> <em>FLOAT_IDENTIFIERS</em> are identifiers previously declared to
have float values. The <em>DOT_ITEM</em> syntax is actually a vector or color operator but it returns a float value. See <a href="r3_3.html#r3_3_1_6_3">Vector Operators</a> or <a href="r3_3.html#r3_3_1_7_5">Color Operators</a> for details. An <em> ARRAY_IDENTIFIER</em> is just the identifier name of a previously declared array, it does not include the <code>[]</code> braces nor the index. The syntax for <em>STRING</em> is in the section <a href="r3_3.html#r3_3_1_9">Strings</a>.</p>
</div>
<a name="r3_3_1_5_1"></a>
<div class="content-level-h5" contains="Literals" id="r3_3_1_5_1">
<h5>3.3.1.5.1 Literals</h5>
<p>Float literals are represented by an optional sign ("+" or
"-") digits, an optional decimal point and more digits. If the
number is an integer you may omit the decimal point and trailing zero. If it
is all fractional you may omit the leading zero. POV-Ray supports scientific
notation for very large or very small numbers. The following are all valid
float literals:</p>
<p>
<code> -2.0 -4 34 3.4e6 2e-5 .3 0.6</code></p>
</div>
<a name="r3_3_1_5_2"></a>
<div class="content-level-h5" contains="Identifiers" id="r3_3_1_5_2">
<h5>3.3.1.5.2 Identifiers</h5>
<p>Float identifiers may be declared to make scene files more readable and to
parameterize scenes so that changing a single declaration changes many
values. An identifier is declared as follows.</p>
<pre>
FLOAT_DECLARATION:
#declare IDENTIFIER = EXPRESSION; |
#local IDENTIFIER = EXPRESSION;
</pre>
<p>Where <em>IDENTIFIER</em> is the name of the identifier up to 40
characters long and <em>EXPRESSION</em> is any valid expression which
evaluates to a float value. </p>
<p class="Note"><strong>Note:</strong> There should be a semi-colon after the
expression in a float declaration. If omitted, it generates a warning
and some macros may not work properly. See <a href="r3_3.html#r3_3_2_2_2">#declare vs. #local</a> for information on identifier scope.</p>
<p>Here are some examples.</p>
<pre>
#declare Count = 0;
#declare Rows = 5.3;
#declare Cols = 6.15;
#declare Number = Rows*Cols;
#declare Count = Count+1;
</pre>
<p>As the last example shows, you can re-declare a float identifier and may
use previously declared values in that re-declaration. There are several
built-in identifiers which POV-Ray declares for you. See Float Expressions: <a href="r3_3.html#r3_3_1_5_6">Built-in Variables</a>
for details.</p>
</div>
<a name="r3_3_1_5_3"></a>
<div class="content-level-h5" contains="Operators" id="r3_3_1_5_3">
<h5>3.3.1.5.3 Operators</h5>
<p><strong>Arithmetic expressions:</strong> Basic math expressions can be
created from float literals, identifiers or functions using the following
operators in this order of precedence...</p>
<table SUMMARY="Arithmetic expressions" width="75%">
<tr>
<td width="30%"><code>( )</code></td>
<td width="70%">expressions in parentheses first</td>
</tr>
<tr>
<td><code>+A -A !A</code></td>
<td>unary minus, unary plus and logical <em>not</em></td>
</tr>
<tr>
<td><code>A*B A/B</code></td>
<td>multiplication and division</td>
</tr>
<tr>
<td><code>A+B A-B</code></td>
<td>addition and subtraction</td>
</tr>
</table>
<p>Relational, logical and conditional expressions may also be created.
However there is a restriction that these types of expressions must be
enclosed in parentheses first. This restriction, which is not imposed by most
computer languages, is necessary because POV-Ray allows mixing of float and
vector expressions. Without the parentheses there is an ambiguity problem.
Parentheses are not required for the unary logical not operator "!"
as shown above. The operators and their precedence are shown here.</p>
<p><strong> Relational expressions:</strong> The operands are arithmetic
expressions and the result is always boolean with 1 for true and 0 for false.
All relational operators have the same precedence.</p>
<table SUMMARY="Relational expressions" width="75%">
<tr>
<td width="30%"><code>(A < B)</code></td>
<td width="70%">A is less than B</td>
</tr>
<tr>
<td><code>(A <= B)</code></td>
<td>A is less than or equal to B</td>
</tr>
<tr>
<td><code>(A = B)</code></td>
<td>A is equal to B (actually abs(A-B)<EPSILON)</td>
</tr>
<tr>
<td><code>(A != B)</code></td>
<td>A is not equal to B (actually abs(A-B)>=EPSILON)</td>
</tr>
<tr>
<td><code>(A >= B)</code></td>
<td>A is greater than or equal to B</td>
</tr>
<tr>
<td><code>(A > B)</code></td>
<td>A is greater than B</td>
</tr>
</table>
<p><strong>Logical expressions:</strong> The operands are converted to
boolean values of 0 for false and 1 for true. The result is always boolean.
All logical operators have the same precedence. </p>
<p class="Note"><strong>Note:</strong> These are not
bit-wise operations, they are logical.</p>
<table SUMMARY="Logical expressions" width="75%">
<tr>
<td width="30%"><code>(A & B)</code></td>
<td width="70%">true only if both A and B are true, false otherwise</td>
</tr>
<tr>
<td><code>(A | B)</code></td>
<td>true if either A or B or both are true</td>
</tr>
</table>
<p><strong>Conditional expressions:</strong> The operand C is boolean while
operands A and B are any expressions. The result is of the same type as A and
B.</p>
<table SUMMARY="Conditional expressions" width="75%">
<tr>
<td width="30%"><code>(C ? A : B)</code></td>
<td width="70%">if C then A else B</td>
</tr>
</table>
<p>Assuming the various identifiers have been declared, the following are
examples of valid expressions...</p>
<pre>
1+2+3 2*5 1/3 Row*3 Col*5
(Offset-5)/2 This/That+Other*Thing
((This<That) & (Other>=Thing)?Foo:Bar)
</pre>
<p>Expressions are evaluated left to right with innermost parentheses
evaluated first, then unary +, - or !, then multiply or divide, then add or
subtract, then relational, then logical, then conditional.</p>
</div>
<a name="r3_3_1_5_4"></a>
<div class="content-level-h5" contains="Functions" id="r3_3_1_5_4">
<h5>3.3.1.5.4 Functions</h5>
<p>POV-Ray defines a variety of built-in functions for manipulating floats,
vectors and strings. Function calls consist of a keyword which specifies the
name of the function followed by a parameter list enclosed in parentheses.
Parameters are separated by commas. For example:</p>
<pre>
keyword(param1,param2)
</pre>
<p>The following are the functions which return float values. They take one
or more float, integer, vector, or string parameters. Assume that <code>
A</code> and <code>B</code> are any valid expression that evaluates to a
float; <code>I</code> is a float which is truncated to integer internally,
<code>S</code>, <code>S1</code>, <code>S2</code> etc. are strings, and <code>
V</code>, <code>V1</code>, <code>V2</code> etc. are any vector
expressions.<code>O</code> is an object identifier to a pre-declared object.</p>
<p><code>abs(A)</code><br>Absolute value of <code>A</code>. If <code>A</code> is negative, returns <code>-A</code> otherwise returns <code>A</code>.</p>
<p><code>acos(A)</code><br>Arc-cosine of <code>A</code>. Returns the angle, measured in radians, whose cosine is <code>A</code>.</p>
<p><code>acosh(A)</code><br>Inverse hyperbolic cosine of <code>A</code>.</p>
<p><code>asc(S)</code><br>Returns an integer value in the range 0 to 255 that is the ASCII value of the first character of the string <code>S</code>. For example <code>asc("ABC")</code> is 65 because that is the value of the character "A".</p>
<p><code>asin(A)</code><br>Arc-sine of <code>A</code>. Returns the angle, measured in radians, whose sine is <code>A</code>.</p>
<p><code>asinh(A)</code><br>Inverse hyperbolic sine of <code>A</code></p>
<p><code>atan2(A,B)</code><br>Arc-tangent of <code>(A/B)</code>. Returns the angle, measured in radians, whose tangent is <code>(A/B)</code>. Returns appropriate value even if <code>B</code> is zero. Use <code>atan2(A,1)</code> to compute usual atan(A) function.</p>
<p><code>atanh(A)</code><br>Inverse hyperbolic tangent of <code>A</code></p>
<p><code>bitwise_and(A,B,...)</code><br>Bitwise <em>AND</em> of two or more float values considered as integers.</p>
<p><code>bitwise_or(A,B,...)</code><br>Bitwise <em>OR</em> of two or more float values considered as integers.</p>
<p><code>bitwise_xor(A,B,...)</code><br>Bitwise <em>XOR</em> of two or more float values considered as integers.</p>
<p class="Note"><strong>Note:</strong> For the three bit-wise functions, each parameter is first converted to integer (so fractional part is ignored), and the computation is performed on a classical int. Do not expect to much precision, as conversion from a double precision number (usually with 52 bits mantissa) to an integer and back to a double precision number is not the best way to keep track of every bit.</p>
<p><code>ceil(A)</code><br>Ceiling of <code>A</code>. Returns the smallest integer greater than <code>A</code>. Rounds up to the next higher integer.</p>
<p><code>cos(A)</code><br>Cosine of <code>A</code>. Returns the cosine of the angle <code>A</code>, where <code>A</code> is measured in radians.</p>
<p><code>cosh(A)</code><br>The hyperbolic cosine of <code>A</code>.</p>
<p><code>defined(</code><em>IDENTIFIER</em><code>)</code><br>Returns <code>true</code> if the identifier is currently defined, <code>false</code> otherwise. This is especially useful for detecting end-of-file after a <code>#read</code> directive because the file identifier is automatically undefined when end-of-file is reached. See <a href="r3_3.html#r3_3_2_3_3">The #read Directive</a> for details.</p>
<p><code>degrees(A)</code><br>Convert radians to degrees. Returns the angle measured in degrees whose value in radians is <code>A</code>. Formula is <em>degrees=A/pi*180.0</em>.</p>
<p><code>dimensions(</code> <em>ARRAY_IDENTIFIER</em> <code>)</code><br>Returns the number of dimensions of a previously declared array identifier. For example if you do <code>#declare MyArray=array[6][10]</code> then <code>dimensions(MyArray)</code> returns the value <code>2</code>.</p>
<p><code>dimension_size(</code> <em> ARRAY_IDENTIFIER, FLOAT</em> <code>)</code><br>Returns the size of a given dimension of a previously declared array identifier. Dimensions are numbered left-to-right starting with 1. For example if you do <code>#declare MyArray=array[6][10]</code> then <code>dimension_size(MyArray,2)</code> returns the value <code>10</code>.</p>
<p><code>div(A,B)</code><br>Integer division. The integer part of <code>(A/B)</code>.</p>
<p><code>exp(A)</code><br>Exponential of <code>A</code>. Returns the value of <em> e</em> raised to the power <code>A</code> where <em>e</em> is the base of the natural logarithm, i.e. the non-repeating value approximately equal to 2.71828182846.</p>
<p><code>file_exists(S)</code><br>Attempts to open the file specified by the string <code>S</code>. The current directory and all library directories specified by the <code>Library_Path</code> or <code>+L</code> options are also searched. See <a href="r3_2.html#r3_2_5_4">Library Paths</a> for details. Returns <code>1</code> if successful and <code>0</code> if unsuccessful.</p>
<p><code>floor(A)</code><br>Floor of <code>A</code>. Returns the largest integer less than <code>A</code>. Rounds down to the next lower integer.</p>
<p><code>inside(O,V)</code><br>It returns either 0.0, when the vector <code>V</code> is outside the object, specified by the object-identifier <code>O</code>, or 1.0 if it is inside.</p>
<p class="Note"><strong>Note:</strong> The <code>inside</code> keyword does not accept object-identifiers to non-solid objects.</p>
<p><code>int(A)</code><br>Integer part of <code>A</code>. Returns the truncated integer part of <code>A</code>. Rounds towards zero.</p>
<p><code>log(A)</code><br>Logarithm of <code>A</code>. Returns the logarithm base <em>10</em> of the value <code>A</code>.</p>
<p><code>ln(A)</code><br>Natural logarithm of <code>A</code>. Returns the natural logarithm base <em>e</em> of the value <code>A</code>.</p>
<p><code>max(A,B,...)</code><br>Maximum of two or more float values. Returns <code>A</code> if <code>A</code> larger than <code>B</code>. Otherwise returns <code>B</code>.</p>
<p><code>min(A,B,...)</code><br>Minimum of two or more float values. Returns <code>A</code> if <code>A</code> smaller than <code>B</code>. Otherwise returns <code>B</code>.</p>
<p><code>mod(A,B)</code><br>Value of <code>A</code> modulo <code>B</code>. Returns the remainder after the integer division of <code>A</code>/<code>B</code>. Formula is <em> mod=((A/B)-int(A/B))*B</em>.</p>
<p><code>pow(A,B)</code><br>Exponentiation. Returns the value of <code>A</code> raised to the power <code>B</code>.</p>
<p class="Note"><strong>Note:</strong> For a negative A and a non-integer B the function has no defined return value. The result then may depend on the platform POV-Ray is compiled on.</p>
<p><code>radians(A)</code><br>Convert degrees to radians. Returns the angle measured in radians whose value in degrees is <code>A</code>. Formula is <em>radians=A*pi/180.0</em>.</p>
<p><code>rand(I)</code><br>Returns the next pseudo-random number from the stream specified by the positive integer <code>I</code>. You must call <code>seed()</code> to initialize a random stream before calling <code>rand()</code>. The numbers are uniformly distributed, and have values between <code>0.0</code> and <code>1.0</code>, inclusively. The numbers generated by separate streams are independent random variables.</p>
<p><code>seed(I)</code><br>Initializes a new pseudo-random stream with the initial seed value <code>I</code>. The number corresponding to this random stream is returned. Any number of pseudo-random streams may be used as shown in the example below:</p>
<pre>
#declare R1 = seed(0);
#declare R2 = seed(12345);
sphere { <rand(R1), rand(R1), rand(R1)>, rand(R2) }
</pre>
<p>Multiple random generators are very useful in situations where you use <code>rand()</code> to place a group of objects, and then decide to use <code>rand()</code> in another location earlier in the file to set some colors or place another group of objects. Without separate <code>rand()</code> streams, all of your objects would move when you added more calls to <code>rand()</code>. This is very annoying.</p>
<p><code>select(A, B, C [,D])</code><br>It can be used with three or four parameters <code>Select</code> compares the first argument with zero, depending on the outcome it will return <code>B</code>, <code>C</code> or <code>D</code>. <code>A,B,C,D</code> can be floats or funtions.</p>
<p>When used with three parameters, if <code>A < 0</code> it will return <code>B</code>, else <code>C</code> (<code>A >= 0</code>).</p>
<p>When used with four parameters, if <code>A < 0</code> it will return B. If <code>A = 0</code> it will return <code>C</code>. Else it will return <code>D</code> (<code>A > 0</code>).</p>
<p>Example:</p>
<p>If <code>A</code> has the consecutive values -2, -1, 0, 1, and 2 :</p>
<pre>
// A = -2 -1 0 1 2
select (A, -1, 0, 1) //returns -1 -1 0 1 1
select (A, -1, 1) //returns -1 -1 1 1 1
</pre>
<p><code>sin(A)</code><br>Sine of <code>A</code>. Returns the sine of the angle <code>A</code>, where <code>A</code> is measured in radians.</p>
<p><code>sinh(A)</code><br>The hyperbolic sine of <code>A</code>.</p>
<p><code>strcmp(S1,S2)</code><br>Compare string <code>S1</code> to <code>S2</code>. Returns a float value zero if the strings are equal, a positive number if <code>S1</code> comes after <code>S2</code> in the ASCII collating sequence, else a negative number.</p>
<p><code>strlen(S)</code><br>Length of <code>S</code>. Returns an integer value that is the number of characters in the string <code>S</code>.</p>
<p><code>sqrt(A)</code><br>Square root of <code>A</code>. Returns the value whose square is <code>A</code>.</p>
<p><code>tan(A)</code><br>Tangent of <code>A</code>. Returns the tangent of the angle <code>A</code>, where <code>A</code> is measured in radians.</p>
<p><code>tanh(A)</code><br>The hyperbolic tangent of <code>A</code>.</p>
<p><code>val(S)</code><br>Convert string <code>S</code> to float. Returns a float value that is represented by the text in string <code>S</code>. For example <code>val("123.45")</code> is 123.45 as a float.</p>
<p><code>vdot(V1,V2)</code><br>Dot product of <code>V1</code> and <code>V2</code>. Returns a float value that is the dot product (sometimes called scalar product) of <code>V1</code> with <code>V2</code>. It is directly proportional to the length of the two vectors and the cosine of the angle between them. Formula is <em>vdot=V1.x*V2.x + V1.y*V2.y + V1.z*V2.z.</em> See the animated demo scene <code>VECT2.POV</code> for an illustration.</p>
<p><code>vlength(V)</code><br>Length of <code>V</code>. Returns a float value that is the length of vector <code>V</code>. Formula is <em>vlength=sqrt(vdot(A,A))</em>. Can be used to compute the distance between two points. <code>Dist=vlength(V2-V1)</code>.</p>
<p>See section <a href="r3_3.html#r3_3_1_8_4">Vector Functions</a> and section <a href="r3_3.html#r3_3_1_9_4">String Functions</a> for other functions which are somewhat float-related but which return vectors and strings. In addition to the above built-in functions, you may also define your own functions using the <code>function</code> keyword. See the section <a href="r3_3.html#r3_3_1_8_3">User-Defined Functions</a> for more details.</p>
</div>
<a name="r3_3_1_5_5"></a>
<div class="content-level-h5" contains="Built-in Constants" id="r3_3_1_5_5">
<h5>3.3.1.5.5 Built-in Constants</h5>
<p>Constants are:</p>
<pre>
FLOAT_BUILT_IN_IDENT:
false | no | off | on | pi | true | yes
</pre>
<p>The built-in constants never change value. They are defined as though
the following lines were at the start of every scene.</p>
<pre>
#declare pi = 3.1415926535897932384626;
#declare true = 1;
#declare yes = 1;
#declare on = 1;
#declare false = 0;
#declare no = 0;
#declare off = 0;
</pre>
<p>The built-in float identifier <code>pi</code> is obviously useful in math
expressions involving circles. The built-in float identifiers <code>
on</code>, <code>off</code>, <code>yes</code>, <code>no</code>, <code>
true</code>, and <code>false</code> are designed for use as boolean
constants.</p>
<p>The built-in float constants <code>on</code>, <code>off</code>, <code>yes</code>, <code>no</code>, <code>true</code>, and <code>false</code> are most often used as boolean values with object modifiers or parameters such as <code><a href="r3_4.html#r3_4_5_5_11">sturm</a></code>, <code><a href="r3_4.html#r3_4_5_5_4">hollow</a></code>, <code><a href="r3_4.html#r3_4_5_1_1">hierarchy</a></code>, <code><a href="r3_4.html#r3_4_5_1_5">smooth</a></code>, <code><a href="r3_4.html#r3_4_4_1_11">media_attenuation</a></code>, and <code><a href="r3_4.html#r3_4_4_1_10">media_interaction</a></code>. Whenever you see syntax of the form <code>keyword</code> <em><code>[Bool]</code></em>, if you simply specify the keyword without the optional boolean then it assumes <code>keyword on</code>. You need not use the boolean but for readability it is a good idea. You must use one of the false booleans or an expression which evaluates to zero to turn it off.</p>
<p class="Note"><strong>Note:</strong> Some of these keywords are <code>on</code> by default, if no keyword is specified.</p>
<p>For example:</p>
<pre>
object { MyBlob } // sturm defaults off, but
// hierarchy defaults on
object { MyBlob sturm } // turn sturm on
object { MyBlob sturm on } // turn sturm on
object { MyBlob sturm off } // turn sturm off
object { MyBlob hierarchy } // does nothing, hierarchy was
// already on
object { MyBlob hierarchy off } // turn hierarchy off
</pre>
</div>
<a name="r3_3_1_5_6"></a>
<div class="content-level-h5" contains="Built-in Variables" id="r3_3_1_5_6">
<h5>3.3.1.5.6 Built-in Variables</h5>
<p>There are several built-in float variables. You can use them to specify
values or to create expressions but you cannot re-declare them to change
their values.</p>
<p>Clock-related are:</p>
<pre>
FLOAT_BUILT-IN_IDENT:
clock | clock_delta | clock_on | final_clock | final_frame
frame_number | initial_clock | initial_frame
</pre>
<p>These keywords allow to use the values of the clock which have been set in the
command line switch options (or INI-file). They represent float or integer values, read from the
animation options. You cannot re-declare these identifiers.</p>
<p><code>clock</code>
<br>The built-in float identifier <code>clock</code> is used to control
animations in POV-Ray. Unlike some animation packages, the action in POV-Ray
animated scenes does not depend upon the integer frame numbers. Rather you
should design your scenes based upon the float identifier <code>
clock</code>. For non-animated scenes its default value is 0 but you can set
it to any float value using the INI file option <code>Clock=</code><em>n.n</em>
or the command-line switch <code>+K</code><em>n.n</em> to pass a single float
value your scene file.</p>
<p>
Other INI options and switches may be used to animate scenes by automatically
looping through the rendering of frames using various values for <code>clock</code>.
By default, the clock value is 0 for the initial frame and 1 for the final frame. All other
frames are interpolated between these values.
<br>For example if your object is supposed to rotate one full turn over the course
of the animation you could specify <code>rotate 360*clock*y</code>. Then as
clock runs from 0 to 1, the object rotates about the y-axis from 0 to 360 degrees.</p>
<p>
Although the value of <code>clock</code> will change from frame-to-frame,
it will never change throughout the parsing of a scene.</p>
<p><code>clock_delta</code>
<br>The built-in float identifier <code>clock_delta</code> returns the amount
of time between clock values in animations in POV-Ray. While most animations
only need the clock value itself, some animation calculations are easier if
you know how long since the last frame. Caution must be used when designing
such scenes. If you render a scene with too few frames, the results may be
different than if you render with more frames in a given time period. On
non-animated scenes, <code>clock_delta</code> defaults to 0. See the section
<a href="r3_2.html#r3_2_1">Animation Options</a> for more details.</p>
<p><code>clock_on</code></p>
<p>With this identifier the status of the clock can be checked: 1 is on, 0 is off.</p>
<pre>
#if(clock_on=0)
//stuff for still image
#else
//some animation
#end
</pre>
<p><code>frame_number</code></p>
<p>If you rather want to define the action in POV-Ray animated scenes depending upon the integer frame numbers, this identifier can be used. It reads the number of the frame currently being rendered.</p>
<pre>
#if(frame_number=1)
//stuff for first image or frame
#end
#if(frame_number=2)
//stuff for second image or frame
#end
#if(frame_number=n)
//stuff for n th image or frame
#end
</pre>
<p><code>initial_clock</code>
<br>This identifier reads the value set through the INI file option <code>Initial_Clock=</code><em>n.n</em>
or the command-line switch <code>+KI</code><em>n.n</em>.</p>
<p><code>final_clock</code>
<br>This identifier reads the value set through the INI file option <code>Final_Clock=</code><em>n.n</em>
or the command-line switch <code>+KF</code><em>n.n</em>.</p>
<p><code>initial_frame</code>
<br>This identifier reads the value set through the INI file option <code>Initial_Frame=</code><em>n</em>
or the command-line switch <code>+KFI</code><em>n</em>.</p>
<p><code>final_frame</code>
<br>This identifier reads the value set through the INI file option <code>Final_Frame=</code><em>n</em>
or the command-line switch <code>+KFF</code><em>n</em>.</p>
<p class="Note"><strong>Note:</strong> These values are the ones actually used. When the option 'cyclic animation' is set,
they could be different from the ones originally set in the options.</p>
<p>Image-size are:</p>
<pre>
FLOAT_BUILT-IN_IDENT:
image_width | image_height
</pre>
<p><code>image_width</code>
<br>This identifier reads the value set through the INI file option <code>Width=</code><em>n</em>
or the command-line switch <code>+W</code><em>n</em>.</p>
<p><code>image_height</code>
<br>This identifier reads the value set through the INI file option <code>Height=</code><em>n</em>
or the command-line switch <code>+H</code><em>n</em>.</p>
<p>You could use these keywords to set the camera ratio (up and right vectors) correctly. The viewing
angle of the camera covers the full width of the rendered image. The camera ratio will always
follow the ratio of the image width to height, regardless of the set image size. Use it like this:</p>
<pre>
up y*image_height
right x*image_width
</pre>
<p>You could also make some items of the scene dependent on the image size:</p>
<pre>
#if (image_width < 300) crand 0.1 #else crand 0.5 #end
or:
image_map {
pattern image_width, image_width { //make pattern resolution
gradient x //dependent of render width
color_map { [ 0.0 ... ] [ 1.0 ... ] }
}
}
</pre>
<p><code>version</code></p>
<pre>
FLOAT_BUILT-IN_IDENT:
version
</pre>
<p>The built-in float variable <code>version</code> contains the current
setting of the version compatibility option. Although this value defaults to
the current POV-Ray version number, the initial value of <code>
version</code> may be set by the INI file option <code>
Version=</code><em>n.n</em> or by the <code>+MV</code><em>n.n</em>
command-line switch. This tells POV-Ray to parse the scene file using syntax
from an earlier version of POV-Ray.</p>
<p>
The INI option or switch only affects the initial setting. Unlike other built-in identifiers, you may change the value of <code>version</code> throughout a scene file. You do not use <code>#declare</code> to change it though. The <code><a href="r3_3.html#r3_3_2_5">#version</a></code> language directive is used to change modes. Such changes may occur several times within scene files.</p>
<p>
Together with the built-in <code>version</code> identifier the <code>#version</code> directive allows you to save and restore the previous values of this compatibility setting. The new <code>#local</code> identifier option is especially useful here. For example suppose <code>mystuff.inc</code> is in <em>version 1</em> format. At the top of the file you could put:</p>
<pre>
#local Temp_Vers = version; // Save previous value
#version 1.0; // Change to 1.0 mode
... // Version 1.0 stuff goes here...
#version Temp_Vers; // Restore previous version
</pre>
<p class="Note"><strong>Note:</strong> There should be a semi-colon after the
float expression in a <code>#version</code> directive. If omitted, it generates
a warning and some macros may not work properly.</p></div>
<a name="r3_3_1_6"></a>
<div class="content-level-h4" contains="Vector Expressions" id="r3_3_1_6">
<h4>3.3.1.6 Vector Expressions</h4>
<p>POV-Ray often requires you to specify a <em>vector</em>. A vector is a set
of related float values. Vectors may be specified using literals, identifiers
or functions which return vector values. You may also create very complex
vector expressions from combinations of any of these using various familiar
operators.</p>
<p>
POV-Ray vectors may have from two to five components but the vast majority
of vectors have three components. Unless specified otherwise, you should
assume that the word <em>vector</em> means a three component vector.
POV-Ray operates in a 3D x, y, z coordinate system and you will use three
component vectors to specify x, y and z values. In some places POV-Ray needs
only two coordinates. These are often specified by a 2D vector called an <em>
UV vector</em>. Fractal objects use 4D vectors. Color expressions use 5D
vectors but allow you to specify 3, 4 or 5 components and use default values
for the unspecified components. Unless otherwise noted, all 2, 4 or 5
component vectors work just like 3D vectors but they have a different number
of components.</p>
<p>
The syntax for combining vector literals into vector expressions is almost
identical to the rules for float expressions. In the syntax for vector
expressions below, some of the syntax items are defined in the section for
float expressions. See <a href="r3_3.html#r3_3_1_5">Float Expressions</a> for those definitions.
Detailed explanations of vector-specific issues are given in the following
sub-sections.</p>
<pre>
VECTOR:
NUMERIC_TERM [SIGN NUMERIC_TERM]
NUMERIC_TERM:
NUMERIC_FACTOR [MULT NUMERIC_FACTOR]
NUMERIC_FACTOR:
VECTOR_LITERAL |
VECTOR_IDENTIFIER |
SIGN NUMERIC_FACTOR |
VECTOR_FUNCTION |
VECTOR_BUILT-IN_IDENT |
( FULL_EXPRESSION ) |
! NUMERIC_FACTOR |
FLOAT
VECTOR_LITERAL:
< FLOAT , FLOAT , FLOAT >
VECTOR_FUNCTION:
min_extent ( OBJECT_IDENTIFIER ) |
max_extent ( OBJECT_IDENTIFIER ) |
trace(OBJECT_IDENTIFIER, VECTOR, VECTOR, [VECTOR_IDENTIFIER] )|
vaxis_rotate( VECTOR , VECTOR , FLOAT ) |
vcross( VECTOR , VECTOR ) |
vrotate( VECTOR , VECTOR ) |
vnormalize( VECTOR ) |
vturbulence(FLOAT, FLOAT, FLOAT, VECTOR)
VECTOR_BUILT-IN_IDENT:
x | y | z | t | u | v
</pre>
<p class="Note"><strong>Note:</strong> <em>VECTOR_IDENTIFIERS</em> are identifiers previously
declared to have vector values.</p>
</div>
<a name="r3_3_1_6_1"></a>
<div class="content-level-h5" contains="Literals" id="r3_3_1_6_1">
<h5>3.3.1.6.1 Literals</h5>
<p>Vector literals consist of two to five float expressions that are
bracketed by angle brackets <code><</code> and <code>></code>. The
terms are separated by commas. For example here is a typical three component
vector:</p>
<pre>
< 1.0, 3.2, -5.4578 >
</pre>
<p>The commas between components are necessary to keep the program from
thinking that the 2nd term is the single float expression <code>
3.2-5.4578</code> and that there is no 3rd term. If you see an error message
such as "Float expected but '>' found instead" then you
probably have missed a comma.</p>
<p>
Sometimes POV-Ray requires you to specify floats and vectors side-by-side.
The rules for vector expressions allow for mixing of vectors with vectors or
vectors with floats so commas are required separators whenever an ambiguity
might arise. For example <code><1,2,3>-4</code> evaluates as a mixed
float and vector expression where 4 is subtracted from each component
resulting in <code><-3,-2,-1></code>. However the comma in <code>
<1,2,3>,-4</code> means this is a vector followed by a float.</p>
<p>
Each component may be a full float expression. For example</p>
<pre>
<This+3,That/3,5*Other_Thing>
</pre>
<p>is a valid vector.</p>
</div>
<a name="r3_3_1_6_2"></a>
<div class="content-level-h5" contains="Identifiers" id="r3_3_1_6_2">
<h5>3.3.1.6.2 Identifiers</h5>
<p>Vector identifiers may be declared to make scene files more readable and
to parameterize scenes so that changing a single declaration changes many
values. An identifier is declared as follows.</p>
<pre>
VECTOR_DECLARATION:
#declare IDENTIFIER = EXPRESSION; |
#local IDENTIFIER = EXPRESSION;
</pre>
<p>Where <em>IDENTIFIER</em> is the name of the identifier up to 40
characters long and <em>EXPRESSION</em> is any valid expression which
evaluates to a vector value.</p>
<p class="Note"><strong>Note:</strong> There should be a semi-colon after the
expression in a vector declaration. If omitted, it generates a warning and
some macros may not work properly. See
<a href="r3_3.html#r3_3_2_2_2">#declare vs. #local</a> for
information on identifier scope.</p>
<p>Here are some examples....</p>
<pre>
#declare Here = <1,2,3>;
#declare There = <3,4,5>;
#declare Jump = <Foo*2,Bar-1,Bob/3>;
#declare Route = There-Here;
#declare Jump = Jump+<1,2,3>;
</pre>
<p class="Note"><strong>Note:</strong> You invoke a vector identifier by using its name without any
angle brackets. As the last example shows, you can re-declare a vector
identifier and may use previously declared values in that re-declaration.
There are several built-in identifiers which POV-Ray declares for you. See
section <a href="r3_3.html#r3_3_1_5_5">Built-in Vector Identifiers</a> for details.</p>
</div>
<a name="r3_3_1_6_3"></a>
<div class="content-level-h5" contains="Operators" id="r3_3_1_6_3">
<h5>3.3.1.6.3 Operators</h5>
<p>Vector literals, identifiers and functions may also be combined in
expressions the same as float values. Operations are performed on a
component-by-component basis. For example <code><1,2,3> +
<4,5,6></code> evaluates the same as <code><1+4,2+5,3+6></code>
or <code><5,7,9></code>. Other operations are done on a similar
component-by-component basis. For example <code>(<1,2,3> =
<3,2,1>)</code> evaluates to <code><0,1,0></code> because the
middle components are equal but the others are not. Admittedly this is not
very useful but it is consistent with other vector operations.</p>
<p>
Conditional expressions such as <code>(C ? A : B)</code> require that <code>
C</code> is a float expression but <code>A</code> and <code>B</code> may be
vector expressions. The result is that the entire conditional evaluates as a
valid vector. For example if <code>Foo</code> and <code>Bar</code> are
floats then <code>(Foo < Bar ? <1,2,3> : <5,6,7>)</code>
evaluates as the vector <code><1,2,3></code> if <code>Foo</code> is
less than <code>Bar</code> and evaluates as <code><5,6,7></code>
otherwise.</p>
<p>
You may use the dot operator to extract a single float component from a vector. Suppose the identifier <code>Spot</code> was previously defined as a vector. Then <code>Spot.x</code> is a float value that is the first component of this x, y, z vector. Similarly <code>Spot.y</code> and <code>Spot.z</code> reference the 2nd and 3rd components. If <code>Spot</code> was a two component UV vector you could use <code>Spot.u</code> and <code>Spot.v</code> to extract the first and second component. For a 4D vector use <code>.x</code>, <code>.y</code>, <code>.z</code>, and <code>.t</code> to extract each float component. The dot operator is also used in color expressions which are covered later.</p>
</div>
<a name="r3_3_1_6_4"></a>
<div class="content-level-h5" contains="Operator Promotion" id="r3_3_1_6_4">
<h5>3.3.1.6.4 Operator Promotion</h5>
<p>You may use a lone float expression to define a vector whose components
are all the same. POV-Ray knows when it needs a vector of a particular type
and will promote a float into a vector if need be. For example the POV-Ray
<code>scale</code> statement requires a three component vector. If you
specify <code>scale 5</code> then POV-Ray interprets this as <code>scale
<5,5,5></code> which means you want to scale by 5 in every
direction.</p>
<p>
Versions of POV-Ray prior to 3.0 only allowed such use of a float as a
vector in various limited places such as <code>scale</code> and <code>
turbulence</code>. However you may now use this trick anywhere. For
example...</p>
<pre>
box{0,1} // Same as box{<0,0,0>,<1,1,1>}
sphere{0,1} // Same as sphere{<0,0,0>,1}
</pre>
<p>When promoting a float into a vector of 2, 3, 4 or 5 components, all
components are set to the float value, however when promoting a vector of a
lower number of components into a higher order vector, all remaining
components are set to zero. For example if POV-Ray expects a 4D vector and
you specify <code>9</code> the result is <code><9,9,9,9></code> but if
you specify <code><7,6></code> the result is <code>
<7,6,0,0></code>.</p>
</div>
<a name="r3_3_1_6_5"></a>
<div class="content-level-h5" contains="Functions" id="r3_3_1_6_5">
<h5>3.3.1.6.5 Functions</h5>
<p>POV-Ray defines a variety of built-in functions for manipulating floats,
vectors and strings. Function calls consist of a keyword which specifies the
name of the function followed by a parameter list enclosed in parentheses.
Parameters are separated by commas. For example:</p>
<pre>
keyword(param1,param2)
</pre>
<p>The following are the functions which return vector values. They take one
or more float, integer, vector, or string parameters. Assume that <code>
A</code> and <code>B</code> are any valid expression that evaluates to a
vector; and <code>F</code> is any float expression.</p>
<p><code>min_extent(OBJECT_IDENTIFIER), max_extent(OBJECT_IDENTIFIER)</code>.
The <code>min_extent</code> and <code>max_extent</code> return the
minimum and maximum coordinates of a #declared object's bounding box (Corner1
and Corner2), in effect allowing you to find the dimensions and location of the object.</p>
<p class="Note"><strong>Note:</strong> This is not perfect, in some cases (such as CSG intersections and
differences or isosurfaces) the bounding box does not represent the actual dimensions
of the object.</p>
<p>Example:</p>
<pre>
#declare Sphere =
sphere {
<0,0,0>, 1
pigment { rgb <1,0,0> }
}
#declare Min = min_extent ( Sphere );
#declare Max = max_extent ( Sphere );
object { Sphere }
box {
Min, Max
pigment { rgbf <1,1,1,0.5> }
}
</pre>
<p>As of version 3.7 experimental support for reading the pixel resolution of an image map was added. This is done by giving an image map pigment identifier to <code>max_extent()</code>, which will then return the resolution of the image map as the x and y values of the returned vector.</p>
<p>One usage of this feature would be when using an image as a background matte.</p>
<p>Example:</p>
<pre>
#declare MatteImage =
pigment {
image_map {
jpeg "YourImage.jpg"
once
}
};
#declare Resolution = max_extent ( MatteImage );
box { 0, Resolution
pigment { MatteImage }
// avoid the scale by warning (z direction)
#declare Resolution = Resolution + <0, 0, 1>;
// some scale factor to fit your needs
scale Resolution*ScaleFactor
}
</pre>
<p><code>trace(OBJECT_IDENTIFIER, A, B, [VECTOR_IDENTIFIER])</code>.
<code>trace</code> helps you finding the exact location of a ray intersecting
with an object's surface. It traces a ray beginning at the point <code>A</code>
in the direction specified by the vector <code>B</code>. If the ray
hits the specified object, this function returns the coordinate where the ray intersected
the object. If not, it returns <code><0,0,0></code>. If a fourth parameter in the
form of a vector identifier is provided, the normal of the object at the intersection
point (not including any normal perturbations due to textures) is stored into that vector.
If no intersection was found, the normal vector is reset to <code><0,0,0></code>.</p>
<p class="Note"><strong>Note:</strong> Checking the normal vector for
<code><0,0,0></code> is the only reliable way to determine whether an
intersection has actually occurred, intersections can and do occur anywhere,
including at <code><0,0,0></code>.</p>
<p>Example:</p>
<pre>
#declare MySphere = sphere { <0, 0, 0>, 1 }
#declare Norm = <0, 0, 0>;
#declare Start = <1, 1, 1>;
#declare Inter=
trace ( MySphere, Start, <0, 0, 0>-Start, Norm );
object {
MySphere
texture {
pigment { rgb 1}
}
}
#if (vlength(Norm)!=0)
cylinder {
Inter, Inter+Norm, .1
texture {
pigment {color red 1}
}
}
#end
</pre>
<p><code>vaxis_rotate(A,B,F)</code> Rotate <code>A</code> about <code>
B</code> by <code>F</code>. Given the x,y,z coordinates of a point in space
designated by the vector <code>A</code>, rotate that point about an arbitrary
axis defined by the vector <code>B</code>. Rotate it through an angle
specified in degrees by the float value <code>F</code>. The result is a
vector containing the new x,y,z coordinates of the point.</p>
<p><code>vcross(A,B)</code> Cross product of <code>A</code> and <code>B</code>.
Returns a vector that is the vector cross product of the two vectors. The
resulting vector is perpendicular to the two original vectors and its length
is equal to the area of the parallelogram defined by them. Or to put in an
other way, the cross product can also be formulated as:<em><code>
AxB = |A| * |B| * sin(angle(A,B)) * perpendicular_unit_vector(A,B)
</code></em> So the length of the resulting vector is proportional to the sine of the
angle between <code>A</code> and <code>B</code>. See the animated demo
scene <code>VECT2.POV</code> for an illustration.</p>
<p><code>vnormalize(A)</code> Normalize vector <code>A</code>. Returns a unit
length vector that is the same direction as <code>A</code>. Formula is <em>
vnormalize(A)=A/vlength(A)</em>.</p>
<p class="Warning"><strong>Warning:</strong> Using <code>vnormalize(<0,0,0>)</code>
will result in an error.</p>
<p><code>vrotate(A,B)</code> Rotate <code>A</code> about origin by <code>
B</code>. Given the x,y,z coordinates of a point in space designated by the
vector <code>A</code>, rotate that point about the origin by an amount
specified by the vector <code>B</code>. Rotate it about the x-axis by an
angle specified in degrees by the float value <code>B.x</code>. Similarly
<code>B.y</code> and <code>B.z</code> specify the amount to rotate in
degrees about the y-axis and z-axis. The result is a vector containing the
new x,y,z coordinates of the point.</p>
<p><code>vturbulence(Lambda, Omega, Octaves, A)</code> Turbulence vector at A. Given the
x,y,z coordinates of a point in space designated by the vector A, return the
turbulence vector for that point based on the numbers given for Lambda,
Omega and Octaves. For the meaning of the parameters, check out the Lambda,
Omega and Octaves sections.<br>
The amount of turbulence can be controlled by
multiplying the turbulence vector by a multiple. The frequency at which the
turbulence vector changes can be controlled by multiplying A with a
multiple. The turbulence vector returned by the function can be added to the
original point A to obtain a turbulated version of the point A. Example :<br>
<code>#declare MyVector = MyVector + Amount * vturbulence(2, 0.5, 6, MyVector * Frequency);</code></p>
<p>See section <a href="r3_3.html#r3_3_1_5_4">Float Functions</a> for other functions which are somewhat vector-related but which return floats. In addition to the above built-in functions, you may also define your own functions using the <code>#macro</code> directive. See the section <a href="r3_3.html#r3_3_2_8">User Defined Macros</a> for more details.</p>
</div>
<a name="r3_3_1_6_6"></a>
<div class="content-level-h5" contains="Built-in Constants" id="r3_3_1_6_6">
<h5>3.3.1.6.6 Built-in Constants</h5>
<p>There are several built-in vector identifiers. You can use them to specify
values or to create expressions but you cannot re-declare them to change
their values. They are:</p>
<pre>
VECTOR_BUILT-IN_IDENT:
x | y | z | t | u | v
</pre>
<p>All built-in vector identifiers never change value. They are defined as
though the following lines were at the start of every scene.</p>
<pre>
#declare x = <1, 0, 0>;
#declare y = <0, 1, 0>;
#declare z = <0, 0, 1>;
#declare t = <0, 0, 0, 1>;
#declare u = <1, 0>;
#declare v = <0, 1>;
</pre>
<p>The built-in vector identifiers <code>x</code>, <code>y</code>, and <code>
z</code> provide much greater readability for your scene files when used in
vector expressions. For example....</p>
<pre>
plane { y, 1} // The normal vector is obviously "y".
plane { <0,1,0>, 1} // This is harder to read.
translate 5*x // Move 5 units in the "x" direction.
translate <5,0,0> // This is less obvious.
</pre>
<p>An expression like <code>5*x</code> evaluates to <code>
5*<1,0,0></code> or <code><5,0,0></code>.</p>
<p>
Similarly <code>u</code> and <code>v</code> may be used in 2D vectors. When
using 4D vectors you should use <code>x</code>, <code>y</code>, <code>
z</code>, and <code>t</code> and POV-Ray will promote <code>x</code>, <code>
y</code>, and <code>z</code> to 4D when used where 4D is required.</p></div>
<a name="r3_3_1_7"></a>
<div class="content-level-h4" contains="Color Expressions" id="r3_3_1_7">
<h4>3.3.1.7 Color Expressions</h4>
<pre>
COLOR:
COLOR_BODY |
color COLOR_BODY | (this means the keyword color or
colour COLOR_BODY colour may optionally precede any color specification)
COLOR_BODY:
COLOR_VECTOR |
COLOR_KEYWORD_GROUP |
COLOR_IDENTIFIER
COLOR_VECTOR:
rgb <3_Term_Vector> |
rgbf <4_Term_Vector> |
rgbt <4_Term_Vector> |
[ rgbft ] <5_Term_Vector> |
srgb <3_Term_Vector> |
srgbf <4_Term_Vector> |
srgbt <4_Term_Vector> |
srgbft <5_Term_Vector>
COLOR_KEYWORD_GROUP:
[ COLOR_KEYWORD_ITEM ]...
COLOR_KEYWORD_ITEM:
COLOR_IDENTIFIER |
red Red_Amount |
blue Blue_Amount |
green Green_Amount |
filter Filter_Amount |
transmit Transmit_Amount
</pre>
<p class="Note"><strong>Note:</strong> <em>COLOR_IDENTIFIERS</em> are identifiers previously declared to
have color values. The 3, 4, and 5 term vectors are usually vector literals
but may be vector expressions or floats promoted to vectors. See
<a href="r3_3.html#r3_3_1_6_4">Operator Promotion</a> and the sections below.</p>
<p>POV-Ray often requires you to specify a color. Colors consist of five
values or color components. The first three are called <code>red</code>,
<code>green</code>, and <code>blue</code>. They specify the intensity of the
primary colors red, green and blue using an additive color system like the
one used by the red, green and blue color phosphors on a color monitor.</p>
<p>
The 4th component, called <code>filter</code>, specifies the amount of
filtered transparency of a substance. Some real-world examples of filtered
transparency are stained glass windows or tinted cellophane. The light
passing through such objects is tinted by the appropriate color as the
material selectively absorbs some frequencies of light while allowing others
to pass through. The color of the object is subtracted from the light passing
through so this is called subtractive transparency.</p>
<p>The 5th component, called <code>transmit</code>, specifies the amount of
non-filtered light that is transmitted through a surface. Some real-world
examples of non-filtered transparency are thin see-through cloth, fine mesh
netting and dust on a surface. In these examples, all frequencies of light
are allowed to pass through tiny holes in the surface. Although the amount of
light passing through is diminished, the color of the light passing through
is unchanged. </p>
<p>The color of the object and the color transmitted through the object
together contribute 100% of the final color. So if <code>transmit</code> is set to 0.9,
the transmitted color contributes 90% and the color of the object
contributes only 10%. This is also true outside of the 0-1 range, so for
example if <code>transmit</code> is set to 1.7, the transmitted color contributes with
170% and the color of the object contributes with minus 70%. Using <code>transmit</code>
values outside of the 0-1 range can be used to create interesting special
effects, but does not correspond to any phenomena seen in the real world.
An example:</p>
<pre>
camera {location -2.5*z look_at 0 orthographic}
box {
0,1
texture {
pigment {
gradient y
colour_map {
[0, red 1]
[1, blue 1]
}
}
finish{ambient 1}
}
texture {
pigment {
gradient x
colour_map {
[0, rgb 0.5 transmit -3]
[1, rgb 0.5 transmit 3]
}
}
finish{ambient 1}
}
translate <-0.5,-0.5,0>
scale <3,2,1>
}
</pre>
<p>When using the <code>transmit</code> value for special effects, you can visualize it this way:
The <code>transmit</code> value means <em>contrast</em>. 1.0 is no change in contrast, 0.5 is
half contrast, 2.0 is double contrast and so on. You could say that
<code>transmit</code> <em>scales</em> the colors. The color of the object is the <em>center value</em>.
All colors will get closer to the center value if <code>transmit</code> is between 0
and 1, and all colors will spread away from the center value if <code>transmit</code>
is greater than 1. If <code>transmit</code> is negative the colors will be inverted
around the center value. Rgb 0.5 is common to use as center value, but
other values can be used for other effects. The center value really is a
color, and non-gray colors can be used for interesting effects. The red,
green and blue components are handled separately.</p>
<p class="Note"><strong>Note:</strong> Earlier versions of POV-Ray used the
keyword <code>alpha</code> to
specify filtered transparency. However that word is often used to describe
non-filtered transparency. For this reason <code>alpha</code> is no longer
used.</p>
<p>
Each of the five components of a color are float values which are normally
in the range between 0.0 and 1.0. However any values, even negatives may be
used.</p>
<p>
Under most circumstances the keyword <code>color</code> is optional and may
be omitted. We also support the British or Canadian spelling <code>
colour</code>. Colors may be specified using vectors, keywords with floats or
identifiers. You may also create very complex color expressions from
combinations of any of these using various familiar operators. The syntax for
specifying a color has evolved since POV-Ray was first released. We have
maintained the original keyword-based syntax and added a short-cut vector
notation. Either the old or new syntax is acceptable however the vector
syntax is easier to use when creating color expressions.</p>
<p>
The syntax for combining color literals into color expressions is almost
identical to the rules for vector and float expressions. In the syntax for
vector expressions, some of the syntax items are defined in the section
for float expressions. See <a href="r3_3.html#r3_3_1_5">Float Expressions</a> for those
definitions. Detailed explanations of color-specific issues are given in the
following sub-sections.</p>
</div>
<a name="r3_3_1_7_1"></a>
<div class="content-level-h5" contains="Color Vectors" id="r3_3_1_7_1">
<h5>3.3.1.7.1 Color Vectors</h5>
<p>The syntax for a color vector is...</p>
<pre>
COLOR_VECTOR:
rgb <3_Term_Vector> |
rgbf <4_Term_Vector> |
rgbt <4_Term_Vector> |
[ rgbft ] <5_Term_Vector>
</pre>
<p>...where the vectors are any valid vector expressions of 3, 4 or 5
components. For example</p>
<pre>
color rgb <1.0, 0.5, 0.2>
</pre>
<p>This specifies a color whose red component is 1.0 or 100% of full
intensity. The green component is 0.5 or 50% of full intensity and the blue
component is 0.2 or 20% of full intensity. Although the filter and transmit
components are not explicitly specified, they exist and are set to their
default values of 0 or no transparency.</p>
<p>
The <code>rgbf</code> keyword requires a four component vector. The 4th
component is the filter component and the transmit component defaults to
zero. Similarly the <code>rgbt</code> keyword requires four components where
the 4th value is moved to the 5th component which is transmit and then the
filter component is set to zero.</p>
<p>
The <code>rgbft</code> keyword allows you to specify all five components.
Internally in expressions all five are always used.</p>
<p>
Under some circumstances, if the vector expression is a 5 component
expression or there is a color identifier in the expression then the <code>
rgbft</code> keyword is optional.</p>
</div>
<a name="r3_3_1_7_2"></a>
<div class="content-level-h5" contains="sRGB Colors" id="r3_3_1_7_2">
<h5>3.3.1.7.2 sRGB Colors</h5>
<p>
While POV-Ray will normally expect colors to be expressed in whatever <em><a href="t2_3.html#t2_3_4_5">working gamma space</a></em> you have set via <code>assumed_gamma</code>, as of version 3.7 the <code>srgb</code>, <code>srgbf</code>, <code>srgbt</code> and <code>srgbft</code> keywords have been added to specify colors encoded according to the sRGB standard (roughly corresponding to a display gamma pre-correction of 2.2). Using these keywords instead of <code>rgb</code>, <code>rgbf</code>, <code>rgbt</code> or <code>rgbft</code>, respectively, instructs POV-Ray to automatically convert the color components to the working gamma space, being approximately equivalent to:</p>
<pre>
Effective_Red_Amount = pow ( Red_Amount, 2.2/AssumedGamma )
Effective_Green_Amount = pow ( Green_Amount, 2.2/AssumedGamma )
Effective_Blue_Amount = pow ( Blue_Amount, 2.2/AssumedGamma )
Effective_Filter_Amount = Filter_Amount
Effective_Transmit_Amount = Transmit_Amount
</pre>
<p class="Note"><strong>Note:</strong> Defining sRGB colors <em>before</em> <code>assumed_gamma</code> has been set will halt parsing and issue a warning.</p>
<p>The syntax is primarily intended for convenience when working with a physically accurate <code>assumed_gamma</code> of 1.0, as many people find this way of specifying colors more intuitive (for instance a value of about <code>srgb 0.5</code> is commonly perceived as a medium grey, despite having an actual brightness of no more than 21.4%), and most image processing software and tools also use gamma pre-corrected colours in their user interface; while those may use slightly different color spaces, sRGB is a good approximation, and also has the advantage of being the official recommendation for the World Wide Web.</p>
<p class="Note"><strong>Note:</strong> Colors specified this way are not a different flavor of colors, but are rather converted <em>on the fly</em> to linear color values. When interpreting such values as a vector or accessing individual components, you will get the linear values rather than the pre-corrected values you originally specified.</p>
<p>
For instance, the following color statements are all fully equivalent (except for rounding errors):</p>
<pre>
#declare Foo = color srgbt <51,76,102,127>/255;
#debug concat("<",vstr(5,Foo,",",0,3),">\n")
#declare Foo = color srgbt <0.2, 0.3, 0.4, 0.5>;
#debug concat("<",vstr(5,Foo,",",0,3),">\n")
#declare Foo = color srgb <0.2, 0.3, 0.4> transmit 0.5;
#debug concat("<",vstr(5,Foo,",",0,3),">\n")
#declare Foo = color rgbt <0.033,0.073,0.133,0.5>;
#debug concat("<",vstr(5,Foo,",",0,3),">\n")
</pre>
<p class="Note"><strong>Note:</strong> The <code>srgb</code>, <code>srgbf</code>, <code>srgbt</code> and <code>srgbft</code> keywords do not affect the way filter or transmit components are interpreted; these are always expected to be linear.</p>
</div>
<a name="r3_3_1_7_3"></a>
<div class="content-level-h5" contains="Color Keywords" id="r3_3_1_7_3">
<h5>3.3.1.7.3 Color Keywords</h5>
<p>The older keyword method of specifying a color is still useful and many
users prefer it.</p>
<pre>
COLOR_KEYWORD_GROUP:
[ COLOR_KEYWORD_ITEM ]...
COLOR_KEYWORD_ITEM:
COLOR_IDENTIFIER |
red Red_Amount | blue Blue_Amount | green Green_Amount |
filter Filter_Amount | transmit Transmit_Amount
</pre>
<p>Although the <code>color</code> keyword at the beginning is optional, it
is more common to see it in this usage. This is followed by any of five
additional keywords <code>red</code>, <code>green</code>, <code>blue</code>,
<code>filter</code>, or <code>transmit</code>. Each of these component
keywords is followed by a float expression. For example</p>
<pre>
color red 1.0 green 0.5
</pre>
<p>This specifies a color whose red component is 1.0 or 100% of full
intensity and the green component is 0.5 or 50% of full intensity. Although
the blue, filter and transmit components are not explicitly specified, they
exist and are set to their default values of 0. The component keywords may be
given in any order and if any component is unspecified its value defaults to
zero. A <em>COLOR_IDENTIFIER</em> can also be specified but it should always
be first in the group. See <a href="r3_3.html#r3_3_1_7_6">Common Color Pitfalls</a> for details.</p>
</div>
<a name="r3_3_1_7_4"></a>
<div class="content-level-h5" contains="Color Identifiers" id="r3_3_1_7_4">
<h5>3.3.1.7.4 Color Identifiers</h5>
<p>Color identifiers may be declared to make scene files more readable and to
parameterize scenes so that changing a single declaration changes many
values. An identifier is declared as follows.</p>
<pre>
COLOR_DECLARATION:
#declare IDENTIFIER = COLOR; |
#local IDENTIFIER = COLOR;
</pre>
<p>Where <em>IDENTIFIER</em> is the name of the identifier up to 40
characters long and <em>COLOR</em> is any valid specification.</p>
<p class="Note"><strong>Note:</strong> There should be a semi-colon at the
end of the declaration. If omitted, it generates a warning and some
macros may not work properly. See <a href="r3_3.html#r3_3_2_2_2">#declare vs. #local</a> for
information on identifier scope.</p>
<p>Here are some examples....</p>
<pre>
#declare White = rgb <1,1,1>;
#declare Cyan = color blue 1.0 green 1.0;
#declare Weird = rgb <Foo*2,Bar-1,Bob/3>;
#declare LightGray = White*0.8;
#declare LightCyan = Cyan red 0.6;
</pre>
<p>As the <code>LightGray</code> example shows you do not need any color
keywords when creating color expressions based on previously declared colors.
The last example shows you may use a color identifier with the keyword style
syntax. Make sure that the identifier comes first before any other component
keywords.</p>
<p>
Like floats and vectors, you may re-define colors throughout a scene but the
need to do so is rare.</p>
</div>
<a name="r3_3_1_7_5"></a>
<div class="content-level-h5" contains="Color Operators" id="r3_3_1_7_5">
<h5>3.3.1.7.5 Color Operators</h5>
<p>Color vectors may be combined in expressions the same as float or vector
values. Operations are performed on a component by component basis. For
example <code>rgb <1.0,0.5,0.2>*0.9</code> evaluates the same as <code>
rgb<1.0,0.5,0.2>*<0.9,0.9,0.9></code> or <code>
rgb<0.9,0.45,0.18></code>. Other operations are done on a similar
component by component basis.</p>
<p>
You may use the dot operator to extract a single component from a color.
Suppose the identifier <code>Shade</code> was previously defined as a color.
Then <code>Shade.red</code> is the float value of the red component of <code>
Shade</code>. Similarly <code>Shade.green</code>, <code>Shade.blue</code>,
<code>Shade.filter</code> and <code>Shade.transmit</code> extract the float
value of the other color components. <code>shade.gray</code> returns the gray value of the
color vector.</p>
</div>
<a name="r3_3_1_7_6"></a>
<div class="content-level-h5" contains="Common Color Pitfalls" id="r3_3_1_7_6">
<h5>3.3.1.7.6 Common Color Pitfalls</h5>
<p>The variety and complexity of color specification methods can lead to some
common mistakes. Here are some things to consider when specifying a
color.</p>
<p>
When using filter transparency, the colors which come through are multiplied
by the primary color components. For example if gray light such as <code>
rgb<0.9,0.9,0.9></code> passes through a filter such as <code>
rgbf<1.0,0.5,0.0,1.0></code> the result is <code>
rgb<0.9,0.45,0.0></code> with the red let through 100%, the green cut
in half from 0.9 to 0.45 and the blue totally blocked. Often users mistakenly
specify a clear object by</p>
<pre>
color filter 1.0
</pre>
<p>but this has implied red, green and blue values of zero. You have just
specified a totally black filter so no light passes through. The correct way
is either</p>
<pre>
color red 1.0 green 1.0 blue 1.0 filter 1.0
</pre>
<p>or</p>
<pre>
color transmit 1.0
</pre>
<p>In the 2nd example it does not matter what the rgb values are. All of
the light passes through untouched. Another pitfall is the use of color
identifiers and expressions with color keywords. For example...</p>
<pre>
color My_Color red 0.5
</pre>
<p>this substitutes whatever was the red component of <code>My_Color</code>
with a red component of 0.5 however...</p>
<pre>
color My_Color + red 0.5
</pre>
<p>adds 0.5 to the red component of <code>My_Color</code> and even less
obvious...</p>
<pre>
color My_Color * red 0.5
</pre>
<p>that cuts the red component in half as you would expect but it also
multiplies the green, blue, filter and transmit components by zero! The part
of the expression after the multiply operator evaluates to <code>
rgbft<0.5,0,0,0,0></code> as a full 5 component color.</p>
<p>
The following example results in no change to <code>My_Color</code>.</p>
<pre>
color red 0.5 My_Color
</pre>
<p>This is because the identifier fully overwrites the previous value. When
using identifiers with color keywords, the identifier should be first.
Another issue to consider: some POV-Ray syntax allows full color
specifications but only uses the rgb part. In these cases it is legal to use
a float where a color is needed. For example:</p>
<pre>
finish { ambient 1 }
</pre>
<p>The <a href="r3_4.html#r3_4_6_3_1">ambient</a> keyword expects a color so the value <code>1</code> is
promoted to <code><1,1,1,1,1></code> which is no problem. However</p>
<pre>
pigment { color 0.4 }
</pre>
<p>is legal but it may or may not be what you intended. The <code>0.4</code>
is promoted to <code><0.4,0.4,0.4,0.4,0.4></code> with the filter and
transmit set to 0.4 as well. It is more likely you wanted...</p>
<pre>
pigment { color rgb 0.4 }
</pre>
<p>in which case a 3 component vector is expected. Therefore the <code>
0.4</code> is promoted to <code><0.4,0.4,0.4,0.0,0.0></code> with
default zero for filter and transmit. Finally there is another problem which
arises when using color dot operators in <code>#declare</code> or <code>#local</code> directives. Consider the directive:</p>
<pre>
#declare MyColor = rgb <0.75, 0.5, 0.75>;
#declare RedAmt = MyColor.red;
</pre>
<p>Now <code>RedAmt</code> should be a float but unfortunately it is a color.
POV-Ray looks at the first keyword after the equals to try to guess what type
of identifier you want. It sees the color identifier <code>MyColor</code>
and assumes you want to declare a color. It then computes the float value as
0.75 then promotes that into <code>
rgbft<0.75,0.75,0.75,0.75,0.75></code>. It would take a major rewrite
to fix this problem so we are just warning you about it. Any of the
following work-arounds will work properly.</p>
<pre>
#declare RedAmt = 0.0+MyColor.red;
#declare RedAmt = 1.0*MyColor.red;
#declare RedAmt = (MyColor.red);
</pre></div>
<a name="r3_3_1_8"></a>
<div class="content-level-h4" contains="Function" id="r3_3_1_8">
<h4>3.3.1.8 Function</h4>
<p>Some objects allow you to specify functions that will be evaluated while rendering to determine the surface of these objects. In this respect functions are quite different to <a href="r3_3.html#r3_3_2_8">macros</a>, which are evaluated at parse time but do not otherwise affect rendering. Additionally you may call these functions anywhere a Float Function is allowed, even during parsing. The syntax is identical to Float Expressions, however, only float functions that apply to float values may be used. Excluded are for example <code><a href="r3_3.html#r3_3_1_5_4">strlen</a></code> or <code><a href="r3_3.html#r3_3_1_5_4">vlength</a></code>. You find a full list of supported float functions in the syntax definition below.</p>
<pre>
FLOAT:
LOGIC_AND [OR LOGIC_AND]
OR:
|
LOGIC_AND:
REL_TERM [AND REL_TERM]
AND:
&REL_TERM:
TERM [REL_OPERATOR TERM]
REL_OPERATOR:
< | <= | >= | > | = | !=
TERM:
FACTOR [SIGN FACTOR]
SIGN:
+ | -
FACTOR:
MOD_EXPRESSION [MULT MOD_EXPRESSION]
MULT:
* | /
EXPRESSION:
FLOAT_LITERAL |
FLOAT_IDENTIFIER |
FLOAT_FUNCTION |
FLOAT_BUILT-IN_IDENT |
FUNCTION_IDENTIFIER |
( FLOAT ) |
IDENTIFIER |
SIGN EXPRESSION
FLOAT_FUNCTION:
abs( FLOAT ) | acos( FLOAT ) | acosh( FLOAT ) | asin( FLOAT ) |
asinh( FLOAT ) | atan( FLOAT) | atanh( FLOAT) |
atan2( FLOAT , FLOAT ) | ceil( FLOAT ) | cos( FLOAT ) |
cosh( FLOAT ) | degrees( FLOAT ) | exp( FLOAT ) |
floor( FLOAT ) | int( FLOAT ) | ln (Float) | log( FLOAT ) |
max( FLOAT , FLOAT, ... ) | min( FLOAT , FLOAT, ... ) |
mod( FLOAT , FLOAT ) | pow( FLOAT , FLOAT ) |
radians( FLOAT ) | sin( FLOAT ) | sinh( FLOAT ) |
sqrt( FLOAT ) | tan( FLOAT ) | tanh( FLOAT ) |
select( FLOAT , FLOAT , FLOAT [, FLOAT] )
FUNCTION_IDENTIFIER:
#local FUNCTION_IDENTIFIER = function { FLOAT } |
#declare FUNCTION_IDENTIFIER = function { FLOAT } |
#local FUNCTION_IDENTIFIER = function(IDENT_LIST) { FLOAT } |
#declare FUNCTION_IDENTIFIER = function(IDENT_LIST) { FLOAT } |
#local FUNCTION_IDENTIFIER = function{SPECIAL_FLOAT_FUNCTION} |
#local VECTOR_IDENTIFIER = function{SPECIAL_VECTOR_FUNCTION} |
#local COLOR_IDENTIFIER = function { SPECIAL_COLOR_FUNCTION } |
IDENT_LIST:
IDENT_ITEM [, IDENT_LIST]
IDENT_ITEM:
x | y | z | u | v | IDENTIFIER
(Note: x = u and y = v)
SPECIAL_FLOAT_FUNCTION:
pattern { PATTERN_BLOCK }
SPECIAL_VECTOR_FUNCTION:
TRANSFORMATION_BLOCK | SPLINE
SPECIAL_COLOR_FUNCTION:
PIGMENT
PATTERN_BLOCK:
PATTERN
</pre>
<p class="Note"><strong>Note:</strong> Only the above mentioned items can be used in user-defined functions.
For example the rand() function is not available.</p>
<p>All of the above mentioned float functions are described in the section
<a href="r3_3.html#r3_3_1_5_4">Float Functions</a>.</p>
</div>
<a name="r3_3_1_8_1"></a>
<div class="content-level-h5" contains="Sum and Product functions" id="r3_3_1_8_1">
<h5>3.3.1.8.1 Sum and Product functions</h5>
<table class="matte" width="390px" cellpadding="0" cellspacing="10">
<tr>
<td width="240px">
<!---<img src="ref_tex/sum.tex" alt="sum function">---><img class="left" width="45px" src="images/8/8e/RefImgSum.png">
</td>
<td>
<code>sum(i, b, n, a)</code>
</td>
</tr>
<tr>
<td>
<p class="caption">The sum function.</p>
</td>
<td></td>
</tr>
</table>
<p></p>
<table class="matte" width="390px" cellpadding="0" cellspacing="10">
<tr>
<td>
<code>prod(i, b, n, a)</code>
</td>
<td width="240px">
<!---<img src="ref_tex/prod.tex" alt="product function">---><img class="left" width="45px" src="images/1/12/RefImgProd.png">
</td>
</tr>
<tr>
<td></td>
<td>
<p class="caption">The product function.</p>
</td>
</tr>
</table>
<p>For both <code>prod</code> and <code>sum</code>: <code>i</code> is any variable name and <code>a</code> is any expression, usually depending on <code>i</code>. <code>b</code> and <code>n</code> are also any expression.</p>
<p class="Note"><strong>Note:</strong> Even though the following example demonstrates just one usage, <em>both</em> the <code>prod</code> and <code>sum</code> functions <em>require</em> a wrapper before use.</p>
<pre>
#declare factorial = function(C) { prod(i, 1, C, i) }
#declare A = factorial(5);
</pre>
<p>The first parameter is the name of the iteration variable. The second is the initial value expression and the third is the final value expression. Those may not depend on the iteration variable but the iteration variable may still be used inside those two expressions (because it happens to already have been defined) but its value is undefined. The last expression is the actual expression which will be iterated through. It may use any variable in scope.</p>
<p>The scope of an iteration variable is the sequence operation function. That is, a iteration variable is only defined when used inside the <code>sum/prod</code> function. Of course <code>sum/prod</code> functions may be nested. However, there is one limit of a maximum of 56 local variable defined simultaneously, which essentially means that in any combination <code>sum/prod</code> functions cannot be nested deeper than 56 levels.</p>
<p>The iteration variable is incremented by one for each step, but its initial and final value may be any value. The iteration will be continued as long as the iteration value is less or equal to the final value.</p>
<p class="Note"><strong>Note:</strong> Because the iteration value is a floating-point variable, adding one will add a certain bias in a long iterations and thus the floating-point precision will be an issue in such a case and needs to be considered by allowing a reasonable error for the final value!</p>
<p>If the expression to be added has a negative sign it will of course in effect be substracted. Thus changing the sign will allow to generate negative values in the sum function. Equally multiplying by <code>1/expression</code> effectively creates a division when used in the prod function.</p>
<p>Obviously to work in the first place the initial value of the result is the neutral element of the operation. That is, a sum calculation starts with <code>0</code> and a product calculation starts with <code>1</code> just like it is assumed in the sum and product functions in 'regular' math.</p>
<p>It should be noted that mathematically either sum or product are redundant because:</p>
<pre>
log10(prod(i, b, n, a)) = sum(i, b, n, log10(a))
</pre>
<p>
which implies a sum can be represented as a product and vice versa, observing
the usual mathematical constraints of logarithms, of course. However, as
logarithms and their inverse (powers) are slow to compute both are provided...</p>
</div>
<a name="r3_3_1_8_2"></a>
<div class="content-level-h5" contains="Functions and Macros" id="r3_3_1_8_2">
<h5>3.3.1.8.2 Functions and Macros</h5>
<p>You can use macros in functions, but the macros will be called only once
when the function is defined, not every time the function is called. You
cannot pass function variables to the macros.</p>
<p>You can pass functions to macros, how to do this is best explained by an example:</p>
<pre>
#macro Foo( Bar, X )
#declare Y = Bar(X);
#declare Z = Bar(Y);
#end
#declare FUNC=function(n){n+2}
Foo(FUNC, 1)
#debug str(Y,5,5)
#debug "n"
#debug str(Z,5,5)
#debug "n"
</pre>
</div>
<a name="r3_3_1_8_3"></a>
<div class="content-level-h5" contains="Declaring User-Defined Float Functions" id="r3_3_1_8_3">
<h5>3.3.1.8.3 Declaring User-Defined Float Functions</h5>
<p>You declare a user defined function using the <code>#declare</code> or
<code>#local</code> directives. By default a function takes three parameters
and you do not have to explicitly specify the parameter names. The default three
parameters are <code>x</code>, <code>y</code> and <code>z</code>. For
example:</p>
<pre>
#declare foo = function { x + y * z }
</pre>
<p>If you need fewer or more parameters you have to explicitly specify the
parameter list. </p>
<p class="Note"><strong>Note:</strong> The <code>x</code> and <code>u</code> as
well as <code>y</code> and <code>v</code> keywords are equivalent so you may not specify
both parameter names. You may not specify two or more parameters with the same
name either. Doing so may result in a parse error or undefined function results.
</p>
<p>The following are valid functions with parameters:</p>
<pre>
#declare foo2 = function(x, y, z) { x + y * z }
#declare foo3 = function(k1, k2, z, y) { x + y * z + k1 * y + k2 }
#declare foo4 = function(h) { h * h + h }
#declare foo4 = function(u, v) { x + y * v } //=u + v*v
#declare foo4 = function(x, v, z) { u + y * v + z } //=x + v*v + z
</pre>
<p><strong>Limits:</strong></p>
<ul>
<li>The minimum number of parameters per function is 1.</li>
<li>The maximum number of allowed parameters per function is 56.</li>
<li>The maximum number of <code>function</code> blocks per scene is 1048575.</li>
<li>The maximum number of operators per function is about 200000. Individual
limits will be different depending on the types of operators used
in the function.</li>
<li>The maximum depth for nesting functions is 1024.</li>
<li>The maximum number of constants in all functions 1048575.</li>
</ul>
<p class="Note"><strong>Note:</strong> Redeclaring functions, directly, is not allowed. The way to do
this is to <code>undef</code> it first.</p>
<p>There is one special float function type. You may declare a
<code>pattern</code> function.</p>
<p class="Note"><strong>Note:</strong> The syntax is identical to that of
patterns, however, you may not specify colors. Its result is always a float and
not a color vector, as returned by a function containing a pigment.</p>
<pre>
#declare foo = function {
pattern {
checker
}
}
</pre>
<p class="Note"><strong>Note:</strong> The number of parameters of special
function types is determined automatically, so you do not need to specify
parameter names.</p>
</div>
<a name="r3_3_1_8_4"></a>
<div class="content-level-h5" contains="Declaring User-Defined Vector Functions" id="r3_3_1_8_4">
<h5>3.3.1.8.4 Declaring User-Defined Vector Functions</h5>
<p>Right now you may only declare vector functions using one of the special
function types. Supported types are <code>transform</code> and
<code>spline</code> functions. For example:</p>
<pre>
#declare foo = function {
transform {
rotate <90, 0, 0>
scale 4
}
}
#declare myvector = foo(4, 3, 7);
#declare foo2 = function {
spline {
linear_spline
0.0, <0,0,0>
0.5, <1,0,0>
1.0, <0,0,0>
}
}
#declare myvector2 = foo2(0.7);
</pre>
<p>Function splines take the vector size into account. That is, a function
containing a spline with five components will also return a five component
vector (aka a color), a function containing a spline with two components will
only return a two component vector and so on.</p>
<p class="Note"><strong>Note:</strong> The number of parameters of special
function types is determined automatically, so you do not need to specify
parameter names.</p>
</div>
<a name="r3_3_1_8_5"></a>
<div class="content-level-h5" contains="Declaring User-Defined Color Functions" id="r3_3_1_8_5">
<h5>3.3.1.8.5 Declaring User-Defined Color Functions</h5>
<p>Right now you may only declare color functions using one of the special
function types. The only supported type is the <code>pigment</code> function.
You may use every valid <code>pigment</code>. This is a very simple example:</p>
<pre>
#declare foo = function {
pigment {
color red 1
}
}
#declare Vec = foo(1,2,3)
</pre>
<p> An example using a pattern:</p>
<pre>
#declare foo = function {
pigment {
crackle
color_map {
[0.3, color Red]
[1.0, color Blue]
}
}
}
#declare Val = foo(2,3,4).gray
</pre>
<p class="Note"><strong>Note:</strong> The number of parameters of special function types is determined
automatically, so you do not need to specify parameter names.</p>
</div>
<a name="r3_3_1_8_6"></a>
<div class="content-level-h5" contains="Internal Pre-Defined Functions" id="r3_3_1_8_6">
<h5>3.3.1.8.6 Internal Pre-Defined Functions</h5>
<p>Several functions are pre-defined. These internal functions can be accessed through
the <code>functions.inc</code>, so it should be included in your scene. The number of required parameters and what they control are also given in the include
file. See the <a href="r3_4.html#r3_4_9_1_7">functions.inc</a> chapter in the Standard Include File section gives more information.</p></div>
<a name="r3_3_1_9"></a>
<div class="content-level-h4" contains="Strings" id="r3_3_1_9">
<h4>3.3.1.9 Strings</h4>
<p>The POV-Ray language requires you to specify a string of characters to be
used as a file name, text for messages or text for a text object. Strings may
be specified using literals, identifiers or functions which return string
values. See <a href="r3_3.html#r3_3_1_9_4">String Functions</a>
for details on string functions. Although you cannot build string expressions
from symbolic operators such as are used with floats, vectors or colors, you
may perform various string operations using string functions. Some applications
of strings in POV-Ray allow for non-printing formatting characters such as
newline or form-feed.</p>
<pre>
STRING:
STRING_FUNCTION |
STRING_IDENTIFIER |
STRING_LITERAL STRING_LITERAL:
"up to 256 ASCII characters"
STRING_REL_TERM:
STRING_LITERAL [STRING_REL_OPERATOR STRING_LITERAL]...
STRING_REL_OPERATOR:
< | <= | = | >= | > | !=
STRING_FUNCTION:
str( FLOAT , INT , INT ) |
concat( STRING , STRING , [STRING ,...]) | chr( INT ) |
substr( STRING , INT , INT ) | strupr( STRING ) |
strlwr( STRING ) | vstr( INT, VECTOR, STRING, INT, INT )
</pre>
</div>
<a name="r3_3_1_9_1"></a>
<div class="content-level-h5" contains="String Literals" id="r3_3_1_9_1">
<h5>3.3.1.9.1 String Literals</h5>
<p>String literals begin with a double quote mark '"' which is followed by up to 256 characters and are terminated by another double quote mark. You can change the character set of strings using the <code>global_settings</code> <code><a href="r3_4.html#r3_4_1_6">charset</a></code> option. The following are all valid string literals:</p>
<p>"Here" "There" "myfile.gif" "textures.inc"</p>
<p class="Note"><strong>Note:</strong> If you need to specify a quote mark in
a string literal you must precede it with a backslash.</p>
<p>Example</p>
<pre> "Joe said \"Hello\" as he walked in."</pre>
<p>is converted to</p>
<pre> Joe said "Hello" as he walked in.</pre>
<p>If you need to specify a backslash, you will have to specify two. For example:</p>
<pre> "This is a backslash \\ and this is two \\\\"</pre>
<p>Is converted to:</p>
<pre>This is a backslash \ and this is two \\</pre>
<p>Windows users need to be especially wary about this as the backslash is also the
windows path separator. For example, the following code does not produce the intended
result:</p>
<pre>
#declare DisplayFont = "c:\windows\fonts\lucon.ttf"
text { ttf DisplayFont "Hello", 2,0 translate y*1.50 }
</pre>
<p>New users might expect this to create a text object using the font
<em>c:\windows\fonts\lucon.ttf</em>. Instead, it will give an error message saying
that it cannot find the font file <em>c:windowsontslucon.ttf</em>.</p>
<p>The correct form of the above code is as follows:</p>
<pre>
#declare DisplayFont = "c:\\windows\\fonts\\lucon.ttf"
text { ttf DisplayFont "Hello", 2,0 translate y*1.50 }
</pre>
<p>The escaping of backslashes occurs in all POV-Ray string literals. There are also
other formatting codes such as <code>\n</code> for new line.
See <a href="r3_3.html#r3_3_2_7_2">Text Formatting</a> for details.</p>
</div>
<a name="r3_3_1_9_2"></a>
<div class="content-level-h5" contains="String Identifiers" id="r3_3_1_9_2">
<h5>3.3.1.9.2 String Identifiers</h5>
<p>String identifiers may be declared to make scene files more readable and
to parameterize scenes so that changing a single declaration changes many
values. An identifier is declared as follows.</p>
<pre>
STRING_DECLARATION:
#declare IDENTIFIER = STRING |
#local IDENTIFIER = STRING
</pre>
<p>Where <em>IDENTIFIER</em> is the name of the identifier up to 40
characters long and <em>STRING</em> is any valid string specification.</p>
<p class="Note"><strong>Note:</strong> Unlike floats, vectors, or colors,
there need not be a semi-colon at the end of the declaration.
See <a href="r3_3.html#r3_3_2_2_2">#declare vs. #local</a>
for information on identifier scope.</p>
<p>Here are some examples...</p>
<pre>
#declare Font_Name = "ariel.ttf"
#declare Inc_File = "myfile.inc"
#declare Name = "John"
#declare Name = concat(Name," Doe")
</pre>
<p>As the last example shows, you can re-declare a string identifier and may
use previously declared values in that re-declaration.</p>
</div>
<a name="r3_3_1_9_3"></a>
<div class="content-level-h5" contains="String Relational Operators" id="r3_3_1_9_3">
<h5>3.3.1.9.3 String Relational Operators</h5>
<p>POV-Ray supports the following string relational operators: <code><strong><</strong> <strong><=</strong> <strong>=</strong> <strong>>=</strong> <strong>></strong> <strong>!=</strong></code> and are subject to standard ASCII collating sequence rules.</p>
<p class="Note"><strong>Note:</strong> These relational operators are nothing more than a <em>shortcut</em> as they are an equivalent to calling the <code><a href="r3_3.html#r3_3_1_5_4">strcmp()</a></code> function.</p>
<p>For example:</p>
<pre>
#if (string1 = string2)
#declare Color = pigment {rgb <0, 1, 0>};
#else
#declare Color = pigment {rgb <1, 0, 0>};
#end
</pre>
<p>Is the same as:</p>
<pre>
#if (strcmp(string1, string2) = 0)
#declare Color = pigment {rgb <0, 1, 0>};
#else
#declare Color = pigment {rgb <1, 0, 0>};
#end
</pre>
<p>This simple example shows just one usage:</p>
<pre>
// perspective (default) camera
camera {
location <0.0, 2.0, -5.0>
look_at <0.0, 0.0, 0.0>
right x*image_width/image_height
}
// create a regular point light source
light_source {
0*x // light's position (translated below)
color rgb <1,1,1> // light's color
translate <0, 20, -20>
}
background {rgb 1}
#declare TestCase = "ABC";
#if (TestCase < "ABD")
#declare Color = pigment {rgb <0, 1, 0>};
#else
#declare Color = pigment {rgb <1, 0, 0>};
#end
sphere {0,1 pigment {Color}}
</pre>
</div>
<a name="r3_3_1_9_4"></a>
<div class="content-level-h5" contains="String Functions" id="r3_3_1_9_4">
<h5>3.3.1.9.4 String Functions</h5>
<p>POV-Ray defines a variety of built-in functions for manipulating floats,
vectors and strings. Function calls consist of a keyword which specifies the
name of the function followed by a parameter list enclosed in parentheses.
Parameters are separated by commas. For example:</p>
<pre>
keyword(param1,param2)
</pre>
<p>The following are the functions which return string values. They take one
or more float, integer, vector, or string parameters. Assume that <code>
A</code> is any valid expression that evaluates to a float; <code>B</code>,
<code>L</code>, and <code>P</code> are floats which are truncated to integers
internally, <code>S</code>, <code>S1</code>, <code>S2</code> etc are
strings.</p>
<p> <code>chr(B)</code> Character whose character value is
<code>B</code>. Returns a single character string. The character value of the
character is specified by an integer <code>B</code> which must be in the
range 0 to 65535 if you specified <code>charset utf8</code> in the
<code>global_settings</code> and 0 to 127 if you specified <code>charset
ascii</code>. Refer to your platform specific documentation if you specified
<code>charset sys</code>. For example <code>chr(70)</code> is the string
"F". When rendering text objects you should be aware that the
characters rendered are dependent on the (TTF) font being used.</p>
<p><code>concat(S1,S2,...)</code> concatenates strings <code>S1</code> and
<code>S2</code>. Returns a string that is the concatenation of all parameter
strings. Must have at least 2 parameters but may have more. For example:</p>
<pre>
concat("Value is ", str(A,3,1), " inches")
</pre>
<p>If the float value <code>A</code> was <code>12.34321</code> the result is
"<code>Value is 12.3 inches</code>", which is a string.</p>
<p><code>datetime()</code> Can be used to return the date and time. It's syntax is:</p>
<pre>
datetime(FLOAT [,STRING])
</pre>
<p>when FLOAT uses the keyword <code>now</code> it will return a string which evaluates to the time elapsed since 2000-01-01, 00:00:00 GMT in days, with a precision of seconds or better. For example:</p>
<pre>
datetime(now)
</pre>
<p>The optional STRING parameter should conform to the same formatting as that of the <em>strftime()</em> C function.</p>
<p>The default for the STRING parameter format is <code>%Y-%m-%d %H:%M:%SZ</code></p>
<p><code>str(A,L,P)</code> Convert float A to a formatted string. Returns a
formatted string representation of float value <code>A</code>. The integer
parameter <code>L</code> specifies the minimum length of the string and the
type of left padding used if the string's representation is shorter than
the minimum. If <code>L</code> is positive then the padding is with blanks.
If <code>L</code> is negative then the padding is with zeros. The overall
minimum length of the formatted string is <em>abs(L)</em>. If the string
needs to be longer, it will be made as long as necessary to represent the
value.</p>
<p>
The integer parameter <code>P</code> specifies the number of digits after
the decimal point. If <code>P</code> is negative then a compiler-specific
default precision is use. Here are some examples:</p>
<pre>
str(123.456, 0, 3) "123.456"
str(123.456, 4, 3) "123.456"
str(123.456, 9, 3) " 123.456"
str(123.456,-9, 3) "00123.456"
str(123.456, 0, 2) "123.46"
str(123.456, 0, 0) "123"
str(123.456, 5, 0) " 123"
str(123.000, 7, 2) " 123.00"
str(123.456, 0,-1) "123.456000" (platform specific)
</pre>
<p><code>strlwr(S)</code> Lower case of <code>S</code>. Returns a new string
in which all upper case letters in the string S1 are converted to lower case.
The original string is not affected. For example <code>strlwr("Hello
There!")</code> results in "hello there!".</p>
<p>
<code>substr(S,P,L)</code> Sub-string from <code>S</code>. Returns a string
that is a subset of the characters in parameter <code>S</code> starting at
the position specified by the integer value <code>P</code> for a length
specified by the integer value <code>L</code>. For example <code>
substr("ABCDEFGHI",4,2)</code> evaluates to the string
"DE". If <em>P+L-1>strlen(S)</em> an error occurs.</p>
<p>
<code>strupr(S)</code> Upper case of <code>S</code>. Returns a new string
in which all lower case letters in the string <code>S</code> are converted to
upper case. The original string is not affected. For example <code>
strupr("Hello There!")</code> results in "HELLO
THERE!".</p>
<p><code>vstr(N,A,S,L,P)</code> Convert vector A to a formatted string. Returns a
formatted string representation of vector <code>A</code> where the elements of
the vector are separated by the string parameter <code>S</code>. The integer
parameter <code>N</code> specifies the amount of dimensions in vector <code>A</code>.
<code>N</code> is autoclipped to the range of 2 to 5, without warning. Specifying a
vector <code>A</code> with more dimensions than given by <code>N</code> will result
in an error.</p>
<p>The integer parameter <code>L</code> specifies the minimum length of the string and the
type of left padding used if the string's representation is shorter than
the minimum. The integer parameter <code>P</code> specifies the number of digits after
the decimal point. If <code>P</code> is negative then a compiler-specific
default precision is use. The function of <code>L</code> and <code>P</code> is the
same as in <code>str</code>. Here are some examples:</p>
<pre>
vstr(2, <1,2>, ", ", 0,1) "1.0, 2.0"
vstr(5, <1,2,3,4,5>, ", ", 0,1) "1.0, 2.0, 3.0, 4.0, 5.0"
vstr(1, 1, ", ", 0,1) "1.0, 1.0"
vstr(2, 1, ", ", 0,1) "1.0, 1.0"
vstr(5, 1, ", ", 0,1) "1.0, 1.0, 1.0, 1.0, 1.0"
vstr(7, 1, ", ", 0,1) "1.0, 1.0, 1.0, 1.0, 1.0"
vstr(3, <1,2>, ", ", 0,1) "1.0, 2.0, 0.0"
vstr(5, <1,2,3>, ", ", 0,1) "1.0, 2.0, 3.0, 0.0, 0.0"
vstr(3, <1,2,3,4>, ", ", 0,1) error
</pre>
<p> See section <a href="r3_3.html#r3_3_1_5_4">Float Functions</a> for other functions which are
somewhat string-related but which return floats. In addition to the above
built-in functions, you may also define your own functions using the
<code><a href="r3_3.html#r3_3_2_8_1">#macro</a></code> directive. See the section
<a href="r3_3.html#r3_3_2_8">User Defined Macros</a> for more details.</p>
</div>
<a name="r3_3_1_9_5"></a>
<div class="content-level-h5" contains="Built-in Variables" id="r3_3_1_9_5">
<h5>3.3.1.9.5 Built-in Variables</h5>
<p>At the moment there is only one built-in string variable. You can use it to specify values or to create expressions but you cannot re-declare it to change it's value.</p>
<p>File-related are:</p>
<pre>
STRING_BUILT-IN_IDENT:
input_file_name
</pre>
<p><code>input_file_name</code><br>The name of the scene input file.</p></div>
<a name="r3_3_1_10"></a>
<div class="content-level-h4" contains="Array" id="r3_3_1_10">
<h4>3.3.1.10 Array</h4>
<p>You may declare arrays of identifiers of up to five dimensions. Any
item that can be declared as an identifier can be declared in an array.</p>
</div>
<a name="r3_3_1_10_1"></a>
<div class="content-level-h5" contains="Declaring Arrays" id="r3_3_1_10_1">
<h5>3.3.1.10.1 Declaring Arrays</h5>
<p>The syntax for declaring an array is as follows:</p>
<pre>
ARRAY_DECLARATION:
#declare IDENTIFIER = array[ INT ][[ INT ]]..[ARRAY_INITIALIZER] |
#local IDENTIFIER = array[ INT ][[ INT ]]..[ARRAY_INITIALIZER]
ARRAY_INITIALIZER:
{ARRAY_ITEM, [ARRAY_ITEM, ]... }
ARRAY_ITEM:
RVALUE | ARRAY_INITIALIZER
</pre>
<p>Where IDENTIFIER is the name of the identifier up to 40 characters long
and INT is a valid float expression which is internally truncated to an
integer which specifies the size of the array. The optional <em>
ARRAY_INITIALIZER</em> is discussed in the next section <a href="r3_3.html#r3_3_1_10_2">Array Initializers</a>.
Here is an example of a one-dimensional, uninitialized array.</p>
<pre>
#declare MyArray = array[10]
</pre>
<p>This declares an uninitialized array of ten elements. The elements are
referenced as <code>MyArray[0]</code> through <code>MyArray[9]</code>. As
yet, the type of the elements are undetermined. Once you have initialized any
element of the array, all other elements can only be defined as that type. An
attempt to reference an uninitialized element results in an error. For
example:</p>
<pre>
#declare MyArray = array[10]
#declare MyArray[5] = pigment{White} //all other elements must
//be pigments too.
#declare MyArray[2] = normal{bumps 0.2} //generates an error
#declare Thing = MyArray[4] //error: uninitialized array element
</pre>
<p>Multi-dimensional arrays up to five dimensions may be declared. For
example:</p>
<pre>
#declare MyGrid = array[4][5]
</pre>
<p>declares a 20 element array of 4 rows and 5 columns. Elements are
referenced from <code>MyGrid[0][0]</code> to <code>MyGrid[3][4]</code>.
Although it is permissible to reference an entire array as a whole, you may
not reference just one dimension of a multi-dimensional array. For
example:</p>
<pre>
#declare MyArray = array[10]
#declare MyGrid = array[4][5]
#declare YourArray = MyArray //this is ok
#declare YourGrid = MyGrid //so is this
#declare OneRow = MyGrid[2] //this is illegal
</pre>
<p>The <code><a href="r3_3.html#r3_3_2_6_2">#ifdef</a></code> and <code><a href="r3_3.html#r3_3_2_6_2">#ifndef</a></code> directives can be used to check whether a specific element of an array has been declared. For methods to determine the size of an array look in the float section for <code><a href="r3_3.html#r3_3_1_5_4">dimensions</a></code> and
<code><a href="r3_3.html#r3_3_1_5_4">dimension_size</a></code>.</p>
<p>Large uninitialized arrays do not take much memory. Internally they are
arrays of pointers so they probably use just 4 bytes per element. Once
initialized with values, they consume memory depending on what you put in
them.</p>
<p>
The rules for local vs. global arrays are the same as any other identifier.</p>
<p class="Note"><strong>Note:</strong> This applies to the entire array. You cannot mix local and global
elements in the same array. See <a href="r3_3.html#r3_3_2_2_2">#declare vs. #local</a> for
information on identifier scope.</p>
<p>Any legitimate use of the <code>#declare</code> directive can also be put into an array. In other words, you can also create multidimensional arrays by making an array of arrays.</p>
</div>
<a name="r3_3_1_10_2"></a>
<div class="content-level-h5" contains="Array Initializers" id="r3_3_1_10_2">
<h5>3.3.1.10.2 Array Initializers</h5>
<p>Because it is cumbersome to individually initialize the elements of an
array, you may initialize it as it is created using array initializer syntax.
For example:</p>
<pre>
#include "colors.inc"
#declare FlagColors = array[3] {Red,White,Blue}
</pre>
<p>Multi-dimensional arrays may also be initialized this way. For
example:</p>
<pre>
#declare Digits =
array[4][10] {
{7,6,7,0,2,1,6,5,5,0},
{1,2,3,4,5,6,7,8,9,0},
{0,9,8,7,6,5,4,3,2,1},
{1,1,2,2,3,3,4,4,5,5}
}
</pre>
<p>The commas are required between elements and between dimensions as shown
in the example.</p></div>
<a name="r3_3_1_11"></a>
<div class="content-level-h4" contains="Spline" id="r3_3_1_11">
<h4>3.3.1.11 Spline</h4>
<p>Splines give you a way to define 'pathways' through your scenes. You specify a
series of points, and POV-Ray interpolates to make a curve connecting them. Every
point along the spline has a numerical value. A good example of a spline is the path
of a moving object: the spline itself would be the path traced out by the object and
the 'parameter' would be time; as time changes the object's position moves along the
spline. Therefore, given a time reference you could use this spline to find the position of the
object. In fact, splines are very well suited to animation.</p>
<p>The syntax is:</p>
<pre>
SPLINE_DECLARATION:
#declare IDENTIFIER =
spline {
[SPLINE_IDENTIFIER] |
[SPLINE_TYPE] |
[Val_1, <Point_1>[,]
Val_2, <Point_2>[,]
...
Val_n, <Point_n>]
}
SPLINE_TYPE:
linear_spline | quadratic_spline | cubic_spline | natural_spline
SPLINE_USAGE:
MySpline(Val) | MySpline(Val, SPLINE_TYPE)
</pre>
<p>The first item gives the type of interpolation. In a <code>linear_spline</code>, straight lines connect each point. In a <code>quadratic_spline</code>, a smooth curve defined by a second-order polynomial connects each point, whereas with <code>cubic_spline</code> and <code>natural_spline</code>, a smooth curve defined by a third-order polynomial connects each point. The default is <code>linear_spline</code>.</p>
<p>Following this are a number of float values each followed by a position vector, all
separated by commas. <code>Val_1</code>, <code>Val_2</code>, etc, are the value
of the spline parameter at each specific point. The points need not be in order of their
parameter values. If two points have the same parameter value, the second point will replace the first.
Beyond the range of the lowest and highest parameter values, the
spline position is fixed at the endpoints.</p>
<p class="Note"><strong>Note:</strong> Because of the way cubic splines
are defined, the first and last points are tangents rather than points on
the spline, <code>cubic_spline</code> interpolation is only valid between the second and
next-to-last points. For all other spline types, interpolation is valid from
the first point to the last point. For t-values outside the valid range,
POV-Ray returns the value of the nearest valid point.</p>
<p>To use a spline, you place the spline identifier followed by the parameter (in
parentheses) wherever you would normally put a vector, similar to a macro. Splines behave mostly
like three-dimensional vectors.</p>
<p>Here is an example:</p>
<pre>
camera { location <0,2,-2> look_at 0 }
light_source { <-5,30,-10> 1 }
#declare MySpline =
spline {
cubic_spline
-.25, <0,0,-1>
0.00, <1,0,0>
0.25, <0,0,1>
0.50, <-1,0,0>
0.75, <0,0,-1>
1.00, <1,0,0>
1.25, <0,0,1>
}
#declare ctr = 0;
#while (ctr < 1)
sphere {
MySpline(ctr),.25
pigment { rgb <1-ctr,ctr,0> }
}
#declare ctr = ctr + 0.01;
#end
</pre>
<p>
You can also have POV-Ray evaluate a spline as if it were a different type
of spline by specifying the type of spline after the value to interpolate at,
for example:</p>
<pre>
sphere{ <2,0,2>, .25 pigment{rgb MySpline(clock, linear_spline)}}
</pre>
<p>
Splines are 'intelligent' when it comes to returning vectors.
The vector with the most components in the spline determines the
size of the returned vector. This allows vectors from two to five components
to be returned by splines.
</p>
<p>
Also, function splines take the vector size into account. That is, a function
containing a spline with five components will also return a five component
vector (aka a color), a function containing a spline with two components will
only return a two component vector and so on.
</p>
</div>
<a name="r3_3_1_11_1"></a>
<div class="content-level-h5" contains="Splines and Macros" id="r3_3_1_11_1">
<h5>3.3.1.11.1 Splines and Macros</h5>
<p>You can pass functions to macros, how to do this is best explained by an example</p>
<pre>
#macro Foo( Bar, Val )
#declare Y = Bar(Val).y;
#end
#declare myspline =
spline {
1, <4,5>
3, <5,5>
5, <6,5>
}
Foo(myspline, 2)
#debug str(Y,5,5)
#debug "\n"
</pre></div>
<a name="r3_3_1_12"></a>
<div class="content-level-h4" contains="Transformations" id="r3_3_1_12">
<h4>3.3.1.12 Transformations</h4>
<p>The supported transformations are <code>rotate</code>, <code>scale</code>, and <code>translate</code>. They are used to turn, size and move an object or texture. A transformation matrix may also be used to specify complex transformations directly. Groups of transformations may be merged together and stored in a transformation identifier.</p>
<p>The syntax for transformations is as follows:</p>
<pre>
TRANSFORMATION:
rotate <Rotate_Amt> | scale <Scale_Amt> |
translate <Translate_Amt> | transform TRANSFORM_IDENTIFIER |
transform { TRANSFORMATION_BLOCK...} |
matrix <Val00, Val01, Val02,
Val10, Val11, Val12,
Val20, Val21, Val22,
Val30, Val31, Val32>
TRANSFORMATION_BLOCK:
TRANSFORM_IDENTIFIER | TRANSFORMATION | inverse
TRANSFORM_DECLARATION:
#declare IDENTIFIER = transform { TRANSFORMATION_BLOCK...} |
#local IDENTIFIER = transform { TRANSFORMATION_BLOCK...}
</pre>
</div>
<a name="r3_3_1_12_1"></a>
<div class="content-level-h5" contains="Translate" id="r3_3_1_12_1">
<h5>3.3.1.12.1 Translate</h5>
<p>Items may be moved by adding a <code>translate</code> modifier. It consists of the keyword <code>translate</code> followed by a vector expression. The three terms of the vector specify the number of units to move in each of the x, y and z directions. Translate moves the element relative to its current position.</p>
<p>For example:</p>
<pre>
sphere { <10, 10, 10>, 1
pigment { Green }
translate <-5, 2, 1>
}
</pre>
<p>will move the sphere from the location <code><10,10,10></code> to <code><5,12,11></code>. It does not move it to the absolute location <code><-5,2,1></code>. Translations are always relative to the item's location before the move. Translating by zero will leave the element unchanged on that axis.</p>
<p>For example:</p>
<pre>
sphere { <10, 10, 10>, 1
pigment { Green }
translate 3*x // evaluates to <3,0,0> so move 3 units
// in the x direction and none along y or z
}
</pre>
</div>
<a name="r3_3_1_12_2"></a>
<div class="content-level-h5" contains="Scale" id="r3_3_1_12_2">
<h5>3.3.1.12.2 Scale</h5>
<p>You may change the size of an object or texture pattern by adding a <code>scale</code> modifier. It consists of the keyword <code>scale</code> followed by a vector expression. The three terms of the vector specify the amount of scaling in each of the x, y and z directions.</p>
<p>Uneven scaling is used to <em> stretch</em> or <em>squish</em> an element. Values larger than one stretch the element on that axis while values smaller than one are used to squish it. Scale is relative to the current element size. If the element has been previously re-sized using scale then scale will size relative to the new size. Multiple scale values may used.</p>
<p>For example:</p>
<pre>
sphere { <0,0,0>, 1
scale <2,1,0.5>
}
</pre>
<p>will stretch and smash the sphere into an ellipsoid shape that is twice the original size along the x-direction, remains the same size in the y-direction and is half the original size in the z-direction.</p>
<p>If a lone float expression is specified it is promoted to a three component vector whose terms are all the same. Thus the item is uniformly scaled by the same amount in all directions.</p>
<p>For example:</p>
<pre>
object {
MyObject
scale 5 // Evaluates as <5,5,5> so uniformly scale
// by 5 in every direction.
}
</pre>
<p>When one of the scaling components is zero, POV-Ray changes this component to 1 since it assumes that 0 means no scaling in this direction. A warning "Illegal Value: Scale X, Y or Z by 0.0. Changed to 1.0." is issued.</p>
</div>
<a name="r3_3_1_12_3"></a>
<div class="content-level-h5" contains="Rotate" id="r3_3_1_12_3">
<h5>3.3.1.12.3 Rotate</h5>
<p>You may change the orientation of an object or texture pattern by adding a <code>rotate</code> modifier. It consists of the keyword <code> rotate</code> followed by a vector expression. The three terms of the vector specify the number of degrees to rotate about each of the x-, y- and z-axes.</p>
<p class="Note"><strong>Note:</strong> The order of the rotations does matter. Rotations occur about the x-axis first, then the y-axis, then the z-axis. If you are not sure if this is what you want then you should only rotate on one axis at a time using multiple rotation statements to get a correct rotation.</p>
<pre>
rotate <0, 30, 0> // 30 degrees around Y axis then,
rotate <-20, 0, 0> // -20 degrees around X axis then,
rotate <0, 0, 10> // 10 degrees around Z axis.
</pre>
<p>Rotation is always performed relative to the axis. Thus if an object is some distance from the axis of rotation it will not only rotate but it will <em>orbit</em> about the axis as though it was swinging around on an invisible string.</p>
<p>POV-Ray uses a left-handed rotation system. Using the famous <em>Computer Graphics Aerobics</em> exercise, you hold up your left hand and point your thumb in the positive direction of the axis of rotation. Your fingers will curl in the positive direction of rotation. Similarly if you point your thumb in the negative direction of the axis your fingers will curl in the negative direction of rotation. See <a href="t2_2.html#t2_2_1_1">Understanding POV-Ray's Coordinate System</a> for an illustration.</p>
</div>
<a name="r3_3_1_12_4"></a>
<div class="content-level-h5" contains="Matrix" id="r3_3_1_12_4">
<h5>3.3.1.12.4 Matrix</h5>
<p>The <code>matrix</code> keyword can be used to explicitly specify the transformation matrix to be used for objects or textures.</p>
<p>Its syntax is:</p>
<pre>
MATRIX:
matrix <Val00, Val01, Val02,
Val10, Val11, Val12,
Val20, Val21, Val22,
Val30, Val31, Val32>
</pre>
<p>Where <em><code>Val00</code></em> through <em><code>Val32</code></em> are float expressions enclosed in angle brackets and separated by commas.</p>
<p class="Note"><strong>Note:</strong> This is not a vector. It is a set of 12 float expressions.</p>
<p> These floats specify the elements of a 4 by 4 matrix with the fourth column implicitly set to <code><0,0,0,1></code>. At any given point <em>P, P=<px, py, pz></em>, is transformed into the point <em>Q, Q=<qx, qy, qz></em>
by</p>
<p>qx = Val00 * px + Val10 * py + Val20 * pz + Val30</p>
<p>qy = Val01 * px + Val11 * py + Val21 * pz + Val31</p>
<p>qz = Val02 * px + Val12 * py + Val22 * pz + Val32</p>
<p>Normally you will not use the matrix keyword because it is less descriptive than the transformation commands and harder to visualize. However the matrix command allows more general transformation effects like <em>shearing</em>. The following matrix causes an object to be sheared along the y-axis.</p>
<pre>
object {
MyObject
matrix < 1, 1, 0,
0, 1, 0,
0, 0, 1,
0, 0, 0 >
}
</pre></div>
<a name="r3_3_2"></a>
<div class="content-level-h3" contains="Language Directives" id="r3_3_2">
<h3>3.3.2 Language Directives</h3>
<p>The POV Scene Language contains several statements called <em>language directives</em> which tell the file parser how to do its job. These directives can appear in almost any place in the scene file - even in the middle of some other statements. They are used to include other text files in the stream of commands, to declare identifiers, to define macros, conditional, or looped parsing and to control other important aspects of scene file processing.</p>
<p>Each directive begins with the hash character <code>#</code> (often called a number sign or pound sign). It is followed by a keyword and optionally other parameters.</p>
<p>In versions of POV-Ray prior to 3.0, the use of this <code>#</code> character was optional. Language directives could only be used between objects, camera or light_source statements and could not appear within those statements. The
exception was the <code> #include</code> which could appear anywhere. Now that all language directives can be used almost anywhere, the <code>#</code> character is mandatory. The following keywords introduce language directives.</p>
<table summary="All language directives">
<tr valign="top">
<td width="25%">
<code>
<a href="r3_3.html#r3_3_2_6_4">#break</a><br>
<a href="r3_3.html#r3_3_2_6_4">#case</a><br>
<a href="r3_3.html#r3_3_2_7_1">#debug</a><br>
<a href="r3_3.html#r3_3_2_2">#declare</a><br>
<a href="r3_3.html#r3_3_2_4">#default</a><br>
<a href="r3_3.html#r3_3_2_6_1">#else</a><br>
<a href="r3_3.html#r3_3_2_6_1">#elseif</a><br>
</code>
</td>
<td width="25%">
<code>
<a href="r3_3.html#r3_3_2_6_1">#end</a><br>
<a href="r3_3.html#r3_3_2_7_1">#error</a><br>
<a href="r3_3.html#r3_3_2_3_2">#fclose</a><br>
<a href="r3_3.html#r3_3_2_3_1">#fopen</a><br>
<a href="r3_3.html#r3_3_2_6_3">#for</a><br>
<a href="r3_3.html#r3_3_2_6_1">#if</a><br>
<a href="r3_3.html#r3_3_2_6_2">#ifdef</a><br>
</code>
</td>
<td width="25%">
<code>
<a href="r3_3.html#r3_3_2_6_2">#ifndef</a><br>
<a href="r3_3.html#r3_3_2_1">#include</a><br>
<a href="r3_3.html#r3_3_2_2">#local</a><br>
<a href="r3_3.html#r3_3_2_8_1">#macro</a><br>
<a href="r3_3.html#r3_3_2_6_4">#range</a><br>
<a href="r3_3.html#r3_3_2_3_3">#read</a><br>
<a href="r3_3.html#r3_3_2_7_1">#render</a><br>
</code>
</td>
<td width="25%">
<code>
<a href="r3_3.html#r3_3_2_7_1">#statistics</a><br>
<a href="r3_3.html#r3_3_2_6_4">#switch</a><br>
<a href="r3_3.html#r3_3_2_2_4">#undef</a><br>
<a href="r3_3.html#r3_3_2_5">#version</a><br>
<a href="r3_3.html#r3_3_2_7_1">#warning</a><br>
<a href="r3_3.html#r3_3_2_6_5">#while</a><br>
<a href="r3_3.html#r3_3_2_3_4">#write</a><br>
</code>
</td>
</tr>
</table>
<p>Earlier versions of POV-Ray considered the keyword <code>#max_intersections</code> and the keyword <code>#max_trace_level</code> to be language directives but they have been moved to the <code>global_settings</code> statement and should be placed there without the <code>#</code> sign. Their use as a directive still works but it generates a warning and may be discontinued in the future.</p></div>
<a name="r3_3_2_1"></a>
<div class="content-level-h4" contains="Include Directive" id="r3_3_2_1">
<h4>3.3.2.1 Include Directive</h4>
<p>The language allows include files to be specified by placing the line</p>
<pre>
#include "filename.inc"
</pre>
<p>at any point in the input file. The filename may be specified by any valid string expression but it usually is a literal string enclosed in double quotes. It may be up to 40 characters long (or your computer's limit), including the two double-quote characters.</p>
<p>The include file is read in as if it were inserted at that point in the file. Using include is almost the same as cutting and pasting the entire contents of this file into your scene.</p>
<p>Include files may be nested. You may have at most 10 nested include files. There is no limit on un-nested include files.</p>
<p>Generally, include files have data for scenes but are not scenes in themselves. By convention scene files end in <code>.pov</code> and include files end with <code>.inc</code>.</p>
<p>It is legal to specify drive and directory information in the file specification however it is discouraged because it makes scene files less portable between various platforms. Use of full lower case is also recommended but not required.</p>
<p class="Note"><strong>Note:</strong> If you ever intend to distribute any source files you make for POV-Ray, remember that some operating systems have case-sensitive file names).</p>
<p>It is typical to put standard include files in a special sub-directory. POV-Ray can only read files in the current directory or one referenced by the <code>Library_Path</code> option or <code>+L</code> switch. See the section
<a href="r3_2.html#r3_2_5_4">Library Paths</a>.</p>
<p>You may use the <code><a href="r3_3.html#r3_3_2_2">#local</a></code> directive to declare identifiers which are temporary in duration and local to the include file in scope. For details see <a href="r3_3.html#r3_3_2_2_2">#declare vs. #local</a>.</p></div>
<a name="r3_3_2_2"></a>
<div class="content-level-h4" contains="Declare and Local Directives" id="r3_3_2_2">
<h4>3.3.2.2 Declare and Local Directives</h4>
<p>Identifiers may be declared and later referenced to make scene files more
readable and to parameterize scenes so that changing a single declaration
changes many values. There are several built-in identifiers which POV-Ray
declares for you. See the sections: <a href="r3_3.html#r3_3_1_5_6">Built-in Variables</a> and <a href="r3_3.html#r3_3_1_5_5">Built-in Vector Identifiers</a> for details.</p>
</div>
<a name="r3_3_2_2_1"></a>
<div class="content-level-h5" contains="Declaring identifiers" id="r3_3_2_2_1">
<h5>3.3.2.2.1 Declaring identifiers</h5>
<p>An identifier is declared as follows.</p>
<pre>
DECLARATION:
#declare [deprecated] IDENTIFIER = RVALUE |
#local [deprecated] IDENTIFIER = RVALUE
RVALUE:
FLOAT; | VECTOR; | COLOR; | STRING | OBJECT | TEXTURE |
PIGMENT | NORMAL | FINISH | INTERIOR | MEDIA | DENSITY |
COLOR_MAP | PIGMENT_MAP | SLOPE_MAP | NORMAL_MAP |
DENSITY_MAP | CAMERA | LIGHT_SOURCE | FOG | RAINBOW |
SKY_SPHERE | TRANSFORM
</pre>
<p class="Note"><strong>Note:</strong> See the section on <a href="r3_3.html#r3_3_2_2_5">Deprecation Support</a> for more information</p>
<p>Where <em>IDENTIFIER</em> is the name of the identifier up to 40
characters long and <em>RVALUE</em> is any of the listed items. They are
called that because they are values that can appear to the <em>right</em> of
the equals sign. The syntax for each is in the corresponding section of this
language reference. Here are some examples.</p>
<pre>
#declare Rows = 5;
#declare Count = Count+1;
#local Here = <1,2,3>;
#declare White = rgb <1,1,1>;
#declare Cyan = color blue 1.0 green 1.0;
#declare Font_Name = "ariel.ttf"
#declare Rod = cylinder {-5*x,5*x,1}
#declare Ring = torus {5,1}
#local Checks = pigment { checker White, Cyan }
object { Rod scale y*5 } // not "cylinder { Rod }"
object {
Ring
pigment { Checks scale 0.5 }
transform Skew
}
</pre>
<p class="Note"><strong>Note:</strong> There should be a semi-colon after the expression in all float,
vector and color identifier declarations. This semi-colon is introduced in POV-Ray
version 3.1. If omitted, it generates a warning and some macros may not work
properly. Semicolons after other declarations are optional.</p>
<p>
Declarations, like most language directives, can appear almost anywhere in the file
- even within other statements. For example:</p>
<pre>
#declare Here=<1,2,3>;
#declare Count=0; // initialize Count
union {
object { Rod translate Here*Count }
#declare Count=Count+1; // re-declare inside union
object { Rod translate Here*Count }
#declare Count=Count+1; // re-declare inside union
object { Rod translate Here*Count }
}
</pre>
<p>As this example shows, you can re-declare an identifier and may use
previously declared values in that re-declaration.</p>
<p class="Note"><strong>Note:</strong> Object identifiers use the generic wrapper statement <code>
object{</code> ... <code>}</code>. You do not need to know what kind of
object it is.</p>
<p>
Declarations may be nested inside each other within limits. In the example
in the previous section you could declare the entire union as a object.
However for technical reasons there are instances where you may not use any
language directive inside the declaration of floats, vectors or color
expressions. Although these limits have been loosened somewhat since POV-Ray
3.1, they still exist.</p>
<p>
Identifiers declared within <code><a href="r3_3.html#r3_3_2_8_1">#macro</a></code> ...
<code><a href="r3_3.html#r3_3_2_6_1">#end</a></code> blocks are not created at the time the macro is defined. They are only created at the time the macro is
actually invoked. Like all other items inside such a #macro definition,
they are ignored when the macro is defined.</p>
</div>
<a name="r3_3_2_2_2"></a>
<div class="content-level-h5" contains="declare vs. local" id="r3_3_2_2_2">
<h5>3.3.2.2.2 declare vs. local</h5>
<p>Identifiers may be declared either global using <code><a href="r3_3.html#r3_3_2_2_1">#declare</a></code> or local using the <code><a href="r3_3.html#r3_3_2_2_1">#local</a></code> directive.</p>
<p>
Those created by the <code>#declare</code> directive are permanent in
duration and global in scope. Once created, they are available throughout the
scene and they are not released until all parsing is complete or until they
are specifically released using <code>#undef</code>. See <a href="r3_3.html#r3_3_2_2_4">Destroying Identifiers</a>.</p>
<p>
Those created by the <code>#local</code> directive are temporary in duration
and local in scope. They temporarily override any identifiers with the same
name. See <a href="r3_3.html#r3_3_2_2_3">Identifier Name Collisions</a>.</p>
<p>
If <code>#local</code> is used inside a <code> #macro</code> then the
identifier is local to that macro. When the macro is invoked and the
<code>#local</code> directive is parsed, the identifier is created. It persists
until the <code>#end</code> directive of the macro is reached. At the <code>#end</code>
directive, the identifier is destroyed. Subsequent invocations of the macro
create totally new identifiers.</p>
<p>
Use of <code>#local</code> within an include file but not in a macro, also
creates a temporary identifier that is local to that include file. When the
include file is included and the <code>#local</code> directive is parsed, the
identifier is created. It persists until the end of the include file is
reached. At the end of file the identifier is destroyed. Subsequent inclusions
of the file create totally new identifiers.</p>
<p>
Use of <code>#local</code> in the main scene file (not in an include file
and not in a macro) is identical to <code>#declare</code>. For clarity sake
you should not use <code>#local</code> in a main file except in a macro.</p>
<p>
There is currently no way to create permanent, yet local identifiers in
POV-Ray.</p>
<p>
Local identifiers may be specifically released early using <code><a href="r3_3.html#r3_3_2_2_4">#undef</a></code> but in general there is no need to do so. See <a href="r3_3.html#r3_3_2_2_4">Destroying Identifiers</a>.</p>
</div>
<a name="r3_3_2_2_3"></a>
<div class="content-level-h5" contains="Identifier Name Collisions" id="r3_3_2_2_3">
<h5>3.3.2.2.3 Identifier Name Collisions</h5>
<p>Local identifiers may have the same names as previously declared
identifiers. In this instance, the most recent, most local identifier takes
precedence. Upon entering an include file or invoking a macro, a new symbol
table is created. When referencing identifiers, the most recently created
symbol table is searched first, then the next most recent and so on back to
the global table of the main scene file. As each macro or include file is
exited, its table and identifiers are destroyed. Parameters passed by value
reside in the same symbol table as the one used for identifiers local to the
macro.</p>
<p>
The rules for duplicate identifiers may seem complicated when multiple-nested
includes and macros are involved, but in actual practice the results are
generally what you intended.</p>
<p>
Consider this example: You have a main scene file called <code>myscene.pov</code>
and it contains</p>
<pre>
#declare A = 123;
#declare B = rgb<1,2,3>;
#declare C = 0;
#include "myinc.inc"
</pre>
<p>Inside the include file you invoke a macro called <code>MyMacro(J,K,L)</code>.
It is not important where <code> MyMacro</code> is defined as long
as it is defined before it is invoked. In this example, it is important
that the macro is invoked from within <code> myinc.inc</code>.</p>
<p>
The identifiers <code>A</code>, <code>B</code>, and <code> C</code> are
generally available at all levels. If either <code> myinc.inc</code> or
<code> MyMacro</code> contain a line such as <code> #declare C=C+1;</code>
then the value <code>C</code> is changed everywhere as you might expect.</p>
<p>
Now suppose inside <code>myinc.inc</code> you do...</p>
<pre>
#local A = 546;
</pre>
<p>The main version of <code>A</code> is hidden and a new <code>A</code> is
created. This new <code>A</code> is also available inside <code>
MyMacro</code> because <code>MyMacro</code> is nested inside <code>
myinc.inc</code>. Once you exit <code>myinc.inc</code>, the local <code>
A</code> is destroyed and the original <code>A</code> with its value of
<code>123</code> is now in effect. Once you have created the local <code>
A</code> inside <code>myinc.inc</code>, there is no way to reference the
original global <code>A</code> unless you <code>#undef A</code> or exit the
include file. Using <code>#undef</code> always undefines the most local
version of an identifier.</p>
<p>
Similarly if <code>MyMacro</code> contained...</p>
<pre>
#local B = box{0,1}
</pre>
<p>then a new identifier <code>B</code> is created local to the macro only.
The original value of <code>B</code> remains hidden but is restored when the
macro is finished. The local <code>B</code> need not have the same
type as the original.</p>
<p>
The complication comes when trying to assign a new value to an identifier at
one level that was declared local at an earlier level. Suppose inside <code>
myinc.inc</code> you do...</p>
<pre>
#local D = 789;
</pre>
<p>If you are inside <code>myinc.inc</code> and you want to increment <code>
D</code> by one, you might try to do...</p>
<pre>
#local D = D + 1;
</pre>
<p>but if you try to do that inside <code>MyMacro</code> you will create a
new <code>D</code> which is local to <code>MyMacro</code> and not the <code>
D</code> which is external to <code>MyMacro</code> but local to <code>
myinc.inc</code>. Therefore you've said "create a <code> MyMacro
D</code> from the value of <code>myinc.inc</code>'s <code> D</code> plus
one". That's probably not what you wanted. Instead you should
do...</p>
<pre>
#declare D = D + 1;
</pre>
<p>You might think this creates a new <code>D</code> that is global but it
actually increments the myinc.inc version of <code>D</code>. Confusing
isn't it? Here are the rules:</p>
<ol>
<li>When referencing an identifier, you always get the most recent, most
local version. By "referencing" we mean using the value of the
identifier in a POV-Ray statement or using it on the right of an equals sign
in either a <code>#declare</code> or <code> #local</code>.</li>
<li>When declaring an identifier using the <code>#local</code> keyword,
the identifier which is created or has a new value assigned, is ALWAYS
created at the current nesting level of macros or include files.</li>
<li>When declaring a NEW, NON-EXISTANT identifier using <code>#declare</code>,
it is created as fully global. It is put in the symbol table of the main
scene file.</li>
<li>When ASSIGNING A VALUE TO AN EXISTING identifier using <code>#declare</code>,
it assigns it to the most recent, most local version at the time.</li>
</ol>
<p>In summary, <code>#local</code> always means "the current
level", and <code>#declare</code> means "global" for new
identifiers and "most recent" for existing identifiers.</p>
</div>
<a name="r3_3_2_2_4"></a>
<div class="content-level-h5" contains="Destroying Identifiers with undef" id="r3_3_2_2_4">
<h5>3.3.2.2.4 Destroying Identifiers with undef</h5>
<p>Identifiers created with <code>#declare</code> will generally persist until parsing is complete. Identifiers created with <code>#local</code> will persist until the end of the macro or include file in which they were created. You may however un-define an identifier using the <code>#undef</code> directive. For example:</p>
<pre>
#undef MyValue
</pre>
<p>If multiple local nested versions of the identifier exist, the most local most recent version is deleted and any identically named identifiers which were created at higher levels will still exist.</p>
<p>See also <a href="r3_3.html#r3_3_2_6_2">The #ifdef and #ifndef Directives</a>.</p>
</div>
<a name="r3_3_2_2_5"></a>
<div class="content-level-h5" contains="Deprecation Support" id="r3_3_2_2_5">
<h5>3.3.2.2.5 Deprecation Support</h5>
<p>The ability to add a <code>deprecated</code> flag to a <code>#declare</code> has been added. This is to aid in migrating scenes away from old constructs (e.g. old textures). The usage is illustrated below:</p>
<pre>
#declare deprecated Col_Glass_Old=color rgbf <0.8, 0.9, 0.85, 0.85>;
#declare deprecated once Col_Glass_Old=... etc
#declare deprecated "Some message" Col_Glass_Old=... etc
</pre>
<p>A deprecated identifier generates no message at the time it is declared, a warning is only issued if it is used.</p>
<p>If the optional <code>once</code> keyword is present it must immediately follow the <code>deprecated</code> keyword and indicates that the warning should only be displayed once per parse.</p>
<p>If the optional message string is present, it will be used as the warning to be displayed if the identifier is used. Otherwise, a message in the form "Identifier Col_Glass_Old was declared deprecated." is used.</p>
<p>An identifier is considered <em>used</em> if it is referenced anywhere (even if in another <code>#declare</code>).</p></div>
<a name="r3_3_2_3"></a>
<div class="content-level-h4" contains="File I/O Directives" id="r3_3_2_3">
<h4>3.3.2.3 File I/O Directives</h4>
<p>You may open, read, write, append, and close plain ASCII text files
while parsing POV-Ray scenes. This feature is primarily intended to help
pass information between frames of an animation. Values such as an
object's position can be written while parsing the current frame and
read back during the next frame. Clever use of this feature could allow a
POV-Ray scene to generate its own include files or write self-modifying
scripts. We trust that users will come up with other interesting uses for
this feature.</p>
<p class="Note"><strong>Note:</strong> Some platform versions of POV-Ray (e.g. Windows)
provide means to restrict the ability of scene files to read and write files.</p>
</div>
<a name="r3_3_2_3_1"></a>
<div class="content-level-h5" contains="The fopen Directive" id="r3_3_2_3_1">
<h5>3.3.2.3.1 The fopen Directive</h5>
<p>Users may open a text file using the <code>#fopen</code> directive. The syntax is as follows:</p>
<pre>
FOPEN_DIRECTIVE:
#fopen FILE_HANDLE_IDENTIFIER "filename" OPEN_TYPE
OPEN_TYPE:
read | write | append
</pre>
<p>Where <em>FILE_HANDLE_IDENTIFIER</em> is an undefined identifier used to reference this file as a file handle, <em>"filename"</em> is any string literal or string expression which specifies the file name. Files opened with the <code>read</code> are open for read only. Those opened with <code>write</code> create a new file with the specified name and it overwrites any existing file with that name. Those opened with <code>append</code> opens a file for writing but appends the text to the end of any existing file.</p>
<p>The file handle identifier created by <code>#fopen</code> is always global and remains in effect (and the file remains open) until the scene parsing is complete or until you <code>#fclose</code> the file. You may use <code>#ifdef</code> <em>FILE_HANDLE_IDENTIFIER</em> to see if a file is open.</p>
</div>
<a name="r3_3_2_3_2"></a>
<div class="content-level-h5" contains="The fclose Directive" id="r3_3_2_3_2">
<h5>3.3.2.3.2 The fclose Directive</h5>
<p>Files opened with the <code>#fopen</code> directive are automatically
closed when scene parsing completes however you may close a file using the
<code>#fclose</code> directive. The syntax is as follows:</p>
<pre>
FCLOSE_DIRECTIVE:
#fclose FILE_HANDLE_IDENTIFIER
</pre>
<p>Where <em>FILE_HANDLE_IDENTIFIER</em> is previously opened file opened
with the <code>#fopen</code> directive.</p>
</div>
<a name="r3_3_2_3_3"></a>
<div class="content-level-h5" contains="The read Directive" id="r3_3_2_3_3">
<h5>3.3.2.3.3 The read Directive</h5>
<p>You may read string, float or vector values from a plain ASCII text file directly into POV-Ray variables using the <code>#read</code> directive. The file must first be opened in <em>read</em> mode using the <code>#fopen</code> directive. The syntax for <code>#read</code> is as follows:</p>
<pre>
READ_DIRECTIVE:
#read (FILE_HANDLE_IDENTIFIER, DATA_IDENTIFIER[,DATA_IDENTIFIER]..)
DATA_IDENTIFIER:
UNDECLARED_IDENTIFIER | FLOAT_IDENTIFIER | VECTOR_IDENTIFIER |
STRING_IDENTIFIER
</pre>
<p>Where <em>FILE_HANDLE_IDENTIFIER</em> is the previously opened file. It is followed by one or more <em>DATA_IDENTIFIER</em>(s) separated by commas. The parentheses around the identifier list are required. A <em>DATA_IDENTIFIER</em> is any undeclared identifier or any previously declared string identifier, float identifier, or vector identifier. Undefined identifiers will be turned into global identifiers of the type determined by the data which is read. Previously defined identifiers remain at whatever global/local status they had when originally created. Type checking is performed to insure that the proper type data is read into these identifiers.</p>
<p>The format of the data to be read must be a series of valid string literals, float literals, or vector literals separated by commas. Expressions or identifiers are not permitted in the data file however unary minus signs and exponential notation are permitted on float values.</p>
<p>If you attempt to read past end-of-file, the file is automatically closed and the <em>FILE_HANDLE_IDENTIFIER</em> is deleted from the symbol table. This means that the boolean function <code>defined(</code><em>FILE_HANDLE_IDENTIFIER</em><code>)</code> can be used to detect end-of-file.</p>
<p>For example:</p>
<pre>
#fopen FILE_HANDLE_IDENTIFIER "mydata.txt" read
#while (defined(FILE_HANDLE_IDENTIFIER))
#read (FILE_HANDLE_IDENTIFIER,Var1,Var2,Var3)
...
#end
</pre>
</div>
<a name="r3_3_2_3_4"></a>
<div class="content-level-h5" contains="The write Directive" id="r3_3_2_3_4">
<h5>3.3.2.3.4 The write Directive</h5>
<p>You may write string, float or vector values to a plain ASCII text file from POV-Ray variables using the <code>#write</code> directive. Additionally it is now possible to write 8, 16, and 32-bit words to an external file.</p>
<p>These words may be arranged in either little or big-endian fashion. Placing one of the following keywords in the argument list of a <code>#write</code> statement causes the values up to the next comma to be written in binary format, using 2's complement integer representation, rounded to the nearest integer in the representable range:</p>
<pre>
uint8 - unsigned byte (0..255)
sint8 - signed byte (-128..127)
uint16be, uint16le - unsigned 16-bit word (0..65535)
sint16be, sint16le - signed 16-bit word (-32768..32767)
sint32be, sint32le - signed 32-bit word (-2^31..2^31-1)
</pre>
<p class="Note"><strong>Note:</strong> Currently, <em>unsigned</em> 32-bit words are not supported.</p>
<p>Keywords ending in "be" will cause the values to be written most significant byte first (<em>big endian</em>, aka network byte order) while those ending in "le" will instead write the least significant byte first (<em>little endian</em>, Intel format).</p>
<p class="Note"><strong>Note:</strong> See the sample macro <code>ARRAYS_WriteDF3</code> in <a href="r3_4.html#r3_4_9_1_1">arrays.inc</a> to see how this feature may be used.</p>
<p>As always, the file must first be opened in either <code>write</code> or <code>append</code> mode using the <code>#fopen</code> directive. The syntax for the <code>#write</code> directive is as follows:</p>
<pre>
WRITE_DIRECTIVE:
#write (FILE_HANDLE_IDENTIFIER, [BINARY_WORD_TYPE,] DATA_ITEM [,DATA_ITEM]...)
BINARY_WORD_TYPE:
uint8 | sint8 | uint16be | uint16le | sint16be | sint16le | sint32be | sint32le
DATA_ITEM:
FLOAT | VECTOR | STRING
</pre>
<p>Where <em>FILE_HANDLE_IDENTIFIER</em> is the previously opened file. It is followed by one or more <em>DATA_ITEM</em>(s) separated by commas. The parentheses around the identifier list are required. A <em>DATA_ITEM</em> is any valid string expression, float expression, or vector expression. Float expressions are evaluated and written as signed float literals. If you require format control, you should use the <code>str(VALUE,L,P)</code> function to convert it to a formatted string. See <a href="r3_3.html#r3_3_1_9_4">String Functions</a> for details on the <code>str</code> function. Vector expressions are evaluated into three signed float constants and are written with angle brackets and commas in standard POV-Ray vector notation. String expressions are evaluated and written as specified.</p>
<p class="Note"><strong>Note:</strong> Data read by the <code>#read</code> directive must have comma
delimiters between values and quotes around string data but the <code>#write</code> directive does not automatically output commas or quotes.</p>
<p>For example the following <code>#read</code> directive reads a string, float and vector.</p>
<pre>
#read (FILE_HANDLE_IDENTIFIER,MyString,MyFloat,MyVect)
</pre>
<p>It expects to read something like:</p>
<pre>
"A quote delimited string", -123.45, <1,2,-3>
</pre>
<p>The POV-Ray code to write this might be:</p>
<pre>
#declare Val1 = -123.45;
#declare Vect1 = <1,2,-3>;
#write (FILE_HANDLE_IDENTIFIER,"\"A quote delimited string\",",Val1,",",Vect1,"\n")
</pre>
<p>See <a href="r3_3.html#r3_3_1_9_1">String Literals</a> and <a href="r3_3.html#r3_3_2_7_2">Text Formatting</a> for details on writing special characters such as quotes, newline, etc.</p></div>
<a name="r3_3_2_4"></a>
<div class="content-level-h4" contains="Default Directive" id="r3_3_2_4">
<h4>3.3.2.4 Default Directive</h4>
<p>POV-Ray creates a default texture when it begins processing. You may change those defaults as described below. Every time you specify a <code><a href="r3_4.html#r3_4_6">texture</a></code> statement, POV-Ray creates a copy of the default texture. Anything you put in the texture statement overrides the default settings. If you attach a <code>pigment</code>, <code>normal</code>, or <code>finish</code> to an object without any texture statement then POV-Ray checks to see if a texture has already been attached. If it has a texture then the pigment, normal or finish will modify the existing texture. If no texture has yet been attached to the object then the default texture is copied and the pigment, normal or finish will modify that texture.</p>
<p>
You may change the default texture, pigment, normal or finish using the language directive <code>#default</code> as follows:</p>
<pre>
DEFAULT_DIRECTIVE:
#default {DEFAULT_ITEM }
DEFAULT_ITEM:
TEXTURE | PIGMENT | NORMAL | FINISH
</pre>
<p>For example:</p>
<pre>
#default {
texture {
pigment { rgb <1,0,0> }
normal { bumps 0.3 }
finish { ambient 0.4 }
}
}
</pre>
<p>This means objects will default to red bumps and slightly high ambient finish. You may also change just part of it like this:</p>
<pre>
#default {
pigment {rgb <1,0,0>}
}
</pre>
<p>This still changes the pigment of the default texture. At any time there is only one default texture made from the default pigment, normal and finish. The example above does not make a separate default for pigments alone.</p>
<p class="Note"><strong>Note:</strong> The special textures <code>tiles</code> and <code>material_map</code>
or a texture with a <code>texture_map</code> may not be used as defaults.</p>
<p>You may change the defaults several times throughout a scene as you wish. Subsequent <code>#default</code> statements begin with the defaults that were in effect at the time. If you wish to reset to the original POV-Ray defaults then you should first save them as follows:</p>
<pre>
//At top of file
#declare Original_Default = texture {}
</pre>
<p>later after changing defaults you may restore it with...</p>
<pre>
#default {texture {Original_Default}}
</pre>
<p>If you do not specify a texture for an object then the default texture is attached when the object appears in the scene. It is not attached when an object is declared.</p>
<p>For example:</p>
<pre>
#declare My_Object =
sphere{ <0,0,0>, 1 } // Default texture not applied
object{ My_Object } // Default texture added here
</pre>
<p>You may force a default texture to be added by using an empty texture statement as follows:</p>
<pre>
#declare My_Thing =
sphere { <0,0,0>, 1 texture {} } // Default texture applied
</pre>
<p>The original POV-Ray defaults for all items are given throughout the documentation under each appropriate section.</p></div>
<a name="r3_3_2_5"></a>
<div class="content-level-h4" contains="Version Directive" id="r3_3_2_5">
<h4>3.3.2.5 Version Directive</h4>
<p>As POV-Ray has evolved from version 1.0 through 3.6 we have made every effort to maintain some amount of backwards compatibility with earlier versions. Some old or obsolete features can be handled directly without any special consideration by the user. Some old or obsolete features can no longer be handled at all. However <em>some</em> old features can still be
used if you warn POV-Ray that this is an older scene. The <code>#version</code> directive can be used to switch version compatibility to different setting several times throughout a scene file. The syntax is:</p>
<pre>
VERSION_DIRECTIVE:
#version FLOAT;
</pre>
<p class="Note"><strong>Note:</strong> There should be a semi-colon after the float expression in a <code>#version</code> directive. This semi-colon is introduced in POV-Ray version 3.1. If omitted, it generates a warning and some macros may not work
properly.</p>
<p>Additionally you may use the <code>Version=</code><em>n.n</em> option or the <code>+MV</code><em>n.n</em> switch to establish the <em>initial</em> setting. See <a href="r3_2.html#r3_2_5_5">Language Version</a> for details. For example, one feature introduced in 2.0 that was incompatible with any 1.0 scene files is the parsing of float expressions. Using <code>#version 1.0</code> turns off expression parsing as well as many warning messages so that nearly all 1.0 files will still work. Naturally the default setting for this option is <code>#version 3.5</code>.</p>
<p class="Note"><strong>Note:</strong> Some obsolete or re-designed features <em>are totally unavailable in the current version of POV-Ray REGARDLESS OF THE VERSION SETTING.</em> Details on these features are noted throughout this documentation.</p>
<p>The built-in float identifier <code>version</code> contains the current setting of the version compatibility option. See
Float Expressions: <a href="r3_3.html#r3_3_1_5_6">Built-in Variables</a>. Together with the built-in <code>version</code> identifier the <code>#version</code> directive allows you to save and restore the previous values of this compatibility setting. The new <code>#local</code> identifier option is especially useful here. For example, suppose <code>mystuff.inc</code> is in version 1 format. At the top of the file you could put:</p>
<pre>
#local Temp_Vers = version; // Save previous value
#version 1.0; // Change to 1.0 mode
... // Version 1.0 stuff goes here...
#version Temp_Vers; // Restore previous version
</pre>
<p>As of version 3.7, there has been a <em>requirement</em> implemented. In order to obtain full version 3.7
functionality, you <em>MUST</em> specify the <code>#version 3.7</code> directive in your scene file. Prior to a <code>#version</code> directive appearing, the version defaults to 3.62. Additionally, if the first <code>#version</code> appears after any other declaration, or a <code>#version</code> directive does not appear at all, a post-parse warning is issued.</p>
<p class="Warning"><strong>Warning:</strong> The version directive and command-line setting no longer provide compatibility with most rendering bugs in versions prior to POV-Ray 3.5. However, compatibility with the scene language is provided for scenes as old as POV-Ray 1.0 just as in all previous versions of POV-Ray. Nevertheless, we strongly recommend you update scenes at least to POV-Ray 3.5 syntax if you plan to use them in future versions of POV-Ray.</p></div>
<a name="r3_3_2_6"></a>
<div class="content-level-h4" contains="Conditional Directives" id="r3_3_2_6">
<h4>3.3.2.6 Conditional Directives</h4>
<p>POV-Ray allows a variety of language directives to implement conditional parsing of various sections of your scene file. This is
especially useful in describing the motion for animations but it has other uses as well. Also available is a <code><a href="r3_3.html#r3_3_2_6_5">#while</a></code> loop directive. You may nest conditional directives 200 levels deep.</p>
</div>
<a name="r3_3_2_6_1"></a>
<div class="content-level-h5" contains="The if...else...end Directives" id="r3_3_2_6_1">
<h5>3.3.2.6.1 The if...else...end Directives</h5>
<p>The simplest conditional directive is the traditional <code>#if</code> directive. The syntax is:</p>
<pre>
IF_DIRECTIVE:
#if ( Cond ) TOKENS... [ELSE_DIRECTIVE] #end
ELSE_DIRECTIVE:
#else TOKENS... |
#elseif ( Cond ) TOKENS... [ELSE_DIRECTIVE]
</pre>
<p>The <em>TOKENS</em> are any number of POV-Ray keyword, identifiers, or punctuation and <code>(</code> <em>Cond</em> <code>)</code> is a float expression that is interpreted as a boolean value. The parentheses and the <code>#end</code> directive are required, an optional <code>#elseif</code> clause is now supported.</p>
<p>A value of 0.0 is <code>false</code> (numbers <= <em>1e-10</em> are also considered zero) while other any non-zero value is <code>true</code>.</p>
<p>For example:</p>
<pre>
#if (Foo)
#debug "Foo is true\n"
#elseif (Bar)
#debug "Foo is false, but Bar is true\n"
#else
#debug "Foo and Bar are both false\n"
#end
</pre>
<p class="Note"><strong>Note:</strong> Nesting directives in the following manner has been known to cause problems during the parse phase.</p>
<pre>
#if( #if(yes) yes #end ) #end
</pre>
</div>
<a name="r3_3_2_6_2"></a>
<div class="content-level-h5" contains="The ifdef and ifndef Directives" id="r3_3_2_6_2">
<h5>3.3.2.6.2 The ifdef and ifndef Directives</h5>
<p>The <code>#ifdef</code> and <code>#ifndef</code> directive are similar to the <code>#if</code> directive however they are used to determine if an identifier has been previously declared.</p>
<pre>
IFDEF_DIRECTIVE:
#ifdef ( IDENTIFIER ) TOKENS... [ELSE_DIRECTIVE] #end
IFNDEF_DIRECTIVE:
#ifndef ( IDENTIFIER ) TOKENS... [ELSE_DIRECTIVE] #end
ELSE_DIRECTIVE:
#else TOKENS... |
#elseif ( Cond ) TOKENS... [ELSE_DIRECTIVE]
</pre>
<p>If the <em>IDENTIFIER</em> exists then the first group of tokens is parsed normally and the second set is skipped. If false, the first set is skipped and the second set is parsed. This is especially useful for replacing an undefined item with a default.</p>
<p>For example:</p>
<pre>
#ifdef (User_Thing)
// This section is parsed if the
// identifier "User_Thing" was
// previously declared
object{User_Thing} // invoke identifier
#else
// This section is parsed if the
// identifier "User_Thing" was not
// previously declared
box{<0,0,0>,<1,1,1>} // use a default
#end
// End of conditional part
</pre>
<p>The <code>#ifndef</code> directive works the opposite. The first group is parsed if the identifier is <em>not</em> defined. As with the <code>#if</code> directive, the <code>#else</code> clause is optional and the <code>#end</code> directive is required.</p>
<p>The <code>#ifdef</code> and <code>#ifndef</code> directives can be used to determine whether a specific element of an array has been assigned.</p>
<pre>
#declare MyArray=array[10]
//#declare MyArray[0]=7;
#ifdef(MyArray[0])
#debug "first element is assigned\n"
#else
#debug "first element is not assigned\n"
#end
</pre>
<p class="Note"><strong>Note:</strong> Additionally, just like the <code>#if</code> directive, the <code>#ifdef</code> and <code>#ifndef</code> directives now also supports an <code>#elseif</code> clause.</p>
</div>
<a name="r3_3_2_6_3"></a>
<div class="content-level-h5" contains="The for Directive" id="r3_3_2_6_3">
<h5>3.3.2.6.3 The for Directive</h5>
<p>A new <code>#for</code> loop construct is now available for simple loops incrementing Identifier from Start to End (inclusive) with the given Step size. The default Step size is +1.0.</p>
<p>The syntax is:</p>
<pre>
#for (Identifier, Start, End [, Step])
//...
#end
</pre>
<p>Consider the following example:</p>
<pre>
#for (i,0,330,30)
sphere { 0,1 translate <0,0,-10> rotate y*i }
#end
</pre>
<p>The <em>Identifier</em> (<em>i</em> in this case) <em>starts</em> at 0 and <em>ends</em> at 330 ... an optional <em>step</em> value of 30 was added.</p>
<p>
Some additional notes:</p>
<ul>
<li>If Step is negative, comparison will be automatically adjusted to match a <em>countdown</em> pattern.</li>
<li>Start, End and Step are evaluated only <em>once</em>.</li>
<li>The loop counter is a full-fledged local variable. Any local variable of the same name already defined before the loop <em>will</em> be overwritten without warning (note that in the main scene file, all local variables outside of macros are effectively global); inside the loop, any tampering with the variable is possible for effect, as long as it is defined as a local numeric variable at the end of each iteration.</li>
<li>After the loop has terminated, the variable will remain defined, typically holding the value End+Step.</li>
<li>The loop counter must <em>not</em> be an array element.</li>
</ul>
<p class="Note"><strong>Note:</strong> See the <em>end</em> of the next section for more information about <code>#break</code> directive behavior.</p>
</div>
<a name="r3_3_2_6_4"></a>
<div class="content-level-h5" contains="The switch, case, range and break Directives" id="r3_3_2_6_4">
<h5>3.3.2.6.4 The switch, case, range and break Directives</h5>
<p>A more powerful conditional is the <code>#switch</code> directive. The syntax is as follows...</p>
<pre>
SWITCH_DIRECTIVE:
#switch ( Switch_Value ) SWITCH_CLAUSE... [#else TOKENS...] #end
SWITCH_CLAUSE:
#case( Case_Value ) TOKENS... [#break] |
#range( Low_Value , High_Value ) TOKENS... [#break]
</pre>
<p>The <em>TOKENS</em> are any number of POV-Ray keyword, identifiers, or punctuation and <code>(</code><em> Switch_Value</em> <code>)</code> is a float expression. The parentheses are required. The <code>#end</code> directive is required. The <em>SWITCH_CLAUSE</em> comes in two varieties. In the <code>#case</code> variety, the float <em>Switch_Value</em> is compared to the float <em>Case_Value</em>. If they are equal, the condition is true.</p>
<p class="Note"><strong>Note:</strong> Values whose difference is less than 1e-10 are considered equal in
case of round off errors.</p>
<p>In the <code>#range</code> variety, <em>Low_Value</em> and <em>High_Value</em> are floats separated by a comma and enclosed in parentheses.</p>
<p>If <em>Low_Value <= Switch_Value</em> and <em>Switch_Value <= High_Value</em> then the condition is true.</p>
<p>In either variety, if the clause's condition is true, that clause's tokens are parsed normally and parsing continues until a <code>#break</code>, <code>#else</code> or <code>#end</code> directive is reached. If the condition is false, POV-Ray skips until another <code>#case</code> or <code>#range</code> is found.</p>
<p>There may be any number of <code>#case</code> or <code>#range</code> clauses in any order you want. If a clause evaluates true but no <code>#break</code> is specified, the parsing will fall through to the next <code>#case</code> or <code>#range</code> and that clause conditional is evaluated. Hitting <code>#break</code> while parsing a successful section causes an immediate jump to the <code>#end</code> without processing subsequent sections, even if a subsequent condition would also have been satisfied.</p>
<p>An optional <code>#else</code> clause may be the last clause. It is only executed if the clause before it was a false clause.</p>
<p>Additionally, within the <code>#switch</code> directive, the <code>#else</code> clause acts like a <code>#range</code> directive that encompasses any possible number. To avoid execution of the <code>#else</code> block, the preceding <code>#case</code> or <code>#range</code> directives must be ended with a <code>#break</code> statement.</p>
<p class="Note"><strong>Note:</strong> The above behavior applies <em>only</em> within the <code>#switch</code> directive.</p>
<p>For example:</p>
<pre>
#switch (VALUE)
#case (TEST_1)
// This section is parsed if VALUE=TEST_1
#break //First case ends
#case (TEST_2)
// This section is parsed if VALUE=TEST_2
#break //Second case ends
#range (LOW_1,HIGH_1)
// This section is parsed if (VALUE>=LOW_1)&(VALUE<=HIGH_1)
#break //Third case ends
#range (LOW_2,HIGH_2)
// This section is parsed if (VALUE>=LOW_2)&(VALUE<=HIGH_2)
#break //Fourth case ends
#else
// This section is parsed if no other case or
// range is true.
#end
</pre>
<p class="Note"><strong>Note:</strong> As of version 3.7 the <code>#break</code> directive can now be used:</p>
<ul>
<li>anywhere within a <code>#case</code> or <code>#range</code> block, to skip to the end of the <code>#switch</code> directive (previously, <code>#break</code> was only useful right before the next <code>#case</code>, <code>#range</code> or <code>#else</code> directive, to indicate that a slip-through was not desired).</li>
<li>anywhere within a loop block (both <code>#while</code> and <code>#for</code>), to terminate the loop.</li>
<li>anywhere within a <code>#macro</code> to preliminarily terminate the macro.</li>
</ul>
<p>Example for the use in a loop:</p>
<pre>
#local R = seed(4711);
#for (I, 1, 100)
#if (rand(R) < I/1000)
#break // terminate loop early
#end
#debug concat(str(I,0,0), " iterations and counting\n")
#end
</pre>
<p>Where multiple <code>#switch</code>, loop and/or <code>#macro</code> blocks are nested, <code>#break</code> will leave only the innermost of these.</p>
</div>
<a name="r3_3_2_6_5"></a>
<div class="content-level-h5" contains="The while...end Directive" id="r3_3_2_6_5">
<h5>3.3.2.6.5 The while...end Directive</h5>
<p>The <code>#while</code> directive is a looping feature that makes it easy to place multiple objects in a pattern or other uses.</p>
<pre>
WHILE_DIRECTIVE:
#while ( Cond ) TOKENS... #end
</pre>
<p>The <em>TOKENS</em> are any number of POV-Ray keyword, identifiers, or punctuation marks which are the <em>body</em> of the loop. The <code>#while</code> directive is followed by a float expression that evaluates to a boolean value. A value of 0.0 is false and any non-zero value is true.</p>
<p class="Note"><strong>Note:</strong> Extremely small values of about 1e-10 are considered zero in case of round off errors.</p>
<p>The parentheses around the expression are required. If the condition is true parsing continues normally until an <code>#end</code> directive is reached. At the end, POV-Ray loops back to the <code>#while</code> directive and the condition is re-evaluated. Looping continues until the condition fails. When it fails, parsing continues after the <code>#end</code> directive.</p>
<p class="Note"><strong>Note:</strong> It is possible for the condition to fail the first time and the loop is totally skipped. It is up to the user to insure that something inside the loop changes so that it eventually terminates.</p>
<p>Here is a properly constructed loop example:</p>
<pre>
#declare Count=0;
#while (Count < 5)
object { MyObject translate x*3*Count }
#declare Count=Count+1;
#end
</pre>
<p>This example places five copies of <code>MyObject</code> in a row spaced three units apart in the x-direction.</p>
<p class="Note"><strong>Note:</strong> See the <em>end</em> of the previous section for more information about <code>#break</code> directive behavior.</p></div>
<a name="r3_3_2_7"></a>
<div class="content-level-h4" contains="User Message Directives" id="r3_3_2_7">
<h4>3.3.2.7 User Message Directives</h4>
<p>With the addition of conditional and loop directives, the POV-Ray language has the potential to be more like an actual programming language. This means that it will be necessary to have some way to see what is going on when trying to debug loops and conditionals. To fulfill this need we have added the ability to print text messages to the screen. You have a choice of five
different text streams to use including the ability to generate a fatal error if you find it necessary. Limited formatting is available for strings output by this method.</p>
</div>
<a name="r3_3_2_7_1"></a>
<div class="content-level-h5" contains="Text Message Streams" id="r3_3_2_7_1">
<h5>3.3.2.7.1 Text Message Streams</h5>
<p>The syntax for a text message is any of the following:</p>
<pre>
TEXT_STREAM_DIRECTIVE:
#debug STRING | #error STRING | #warning STRING
</pre>
<p>Where <em>STRING</em> is any valid string of text including string
identifiers or functions which return strings. For example:</p>
<pre>
#switch (clock*360)
#range (0,180)
#debug "Clock in 0 to 180 range\n"
#break
#range (180,360)
#debug "Clock in 180 to 360 range\n"
#break
#else
#warning "Clock outside expected range\n"
#warning concat("Value is:",str(clock*360,5,0),"\n")
#end
</pre>
<p>There are seven distinct <a href="r3_2.html#r3_2_7_1">text streams</a> that POV-Ray uses for output. You
may output only to three of them. On some versions of POV-Ray, each stream is
designated by a particular color. Text from these streams are displayed
whenever it is appropriate so there is often an intermixing of the text. The
distinction is only important if you choose to turn some of the streams off
or to direct some of the streams to text files. On some systems you may be
able to review the streams separately in their own scroll-back buffer. See
<a href="r3_2.html#r3_2_7_3">Directing Text Streams to Files</a> for details on re-directing the
streams to a text file.</p>
<p>
Here is a description of how POV-Ray uses each stream. You may use them for
whatever purpose you want except note that use of the <code>#error</code>
stream causes a fatal error after the text is displayed.</p>
<p> <strong>Debug:</strong> This stream displays debugging messages. It was
primarily designed for developers but this and other streams may also be used
by the user to display messages from within their scene files.</p>
<p>
<strong>Error:</strong> This stream displays fatal error messages. After
displaying this text, POV-Ray will terminate. When the error is a scene
parsing error, you may be shown several lines of scene text that leads up to
the error.</p>
<p>
<strong>Warning:</strong> This stream displays warning messages during the
parsing of scene files and other warnings. Despite the warning, POV-Ray can
continue to render the scene.</p>
<p>The <code>#render</code> and <code>#statistsics</code> could be accessed in previous versions.
Their output is now redirected to the <code>#debug</code> stream.
The <code>#banner</code> and <code>#status</code> streams can not be accessed by the user.</p>
</div>
<a name="r3_3_2_7_2"></a>
<div class="content-level-h5" contains="Text Formatting" id="r3_3_2_7_2">
<h5>3.3.2.7.2 Text Formatting</h5>
<p>Some escape sequences are available to include non-printing control
characters in your text. These sequences are similar to those used in string
literals in the C programming language. The sequences are:</p>
<table SUMMARY="All character escape sequences" width="100%">
<tr>
<td width="25%"><code>"\a"</code></td>
<td width="65%">Bell or alarm,</td>
<td width="10%">0x07</td>
</tr>
<tr>
<td><code>"\b"</code></td>
<td>Backspace,</td>
<td>0x08</td>
</tr>
<tr>
<td><code>"\f"</code></td>
<td>Form feed,</td>
<td>0x0C</td>
</tr>
<tr>
<td><code>"\n"</code></td>
<td>New line (line feed)</td>
<td>0x0A</td>
</tr>
<tr>
<td><code>"\r"</code></td>
<td>Carriage return</td>
<td>0x0D</td>
</tr>
<tr>
<td><code>"\t"</code></td>
<td>Horizontal tab</td>
<td>0x09</td>
</tr>
<tr>
<td><code>"\uNNNN"</code></td>
<td>Unicode character code NNNN</td>
<td>0xNNNN</td>
</tr>
<tr>
<td><code>"\v"</code></td>
<td>Vertical tab</td>
<td>0x0B</td>
</tr>
<tr>
<td><code>"\0"</code></td>
<td>Null</td>
<td>0x00</td>
</tr>
<tr>
<td><code>"\\"</code></td>
<td>Backslash</td>
<td>0x5C</td>
</tr>
<tr>
<td><code>"\'"</code></td>
<td>Single quote</td>
<td>0x27</td>
</tr>
<tr>
<td><code>"\""</code></td>
<td>Double quote</td>
<td>0x22</td>
</tr>
</table>
<p>For example:</p>
<pre>
#debug "This is one line.\nBut this is another\n"
</pre>
<p>Depending on what platform you are using, they may not be fully supported
for console output. However they will appear in any text file if you
re-direct a stream to a file.</p></div>
<a name="r3_3_2_8"></a>
<div class="content-level-h4" contains="User Defined Macros" id="r3_3_2_8">
<h4>3.3.2.8 User Defined Macros</h4>
<p>POV-Ray 3.1 introduced user defined macros with parameters. This feature,
along with the ability to declare <code>#local</code> variables, turned the
POV-Ray Language into a fully functional programming language. Consequently,
it is now possible to write scene generation tools in POV-Ray's own language
that previously required external utilities.</p>
</div>
<a name="r3_3_2_8_1"></a>
<div class="content-level-h5" contains="The macro Directive" id="r3_3_2_8_1">
<h5>3.3.2.8.1 The macro Directive</h5>
<p>The syntax for declaring a macro is:</p>
<pre>
MACRO_DEFINITION:
#macro IDENTIFIER ([PARAM_IDENT] [, PARAM_IDENT]... ) TOKENS... #end
</pre>
<p>Where <em>IDENTIFIER</em> is the name of the macro and <em>PARAM_IDENT</em> is a list of zero or more formal parameter identifiers separated by commas and enclosed by parentheses. The parentheses are required even if no parameters are specified.</p>
<p>The <em>TOKENS</em> are any number of POV-Ray keyword, identifiers, or punctuation marks which are the <em> body</em> of the macro. The body of the macro may contain almost any POV-Ray syntax items you desire. It is terminated by the <code>#end</code> directive.</p>
<p class="Note"><strong>Note:</strong> Any conditional directives such as <code>#if</code>...<code>#end</code>, <code>#while</code>...<code>#end</code>, etc. must be fully nested inside or outside the macro so that the corresponding <code>#end</code> directives pair-up properly.</p>
<p>A macro must be declared before it is invoked. All macro names are global in scope and permanent in duration. You may redefine a macro by another <code>#macro</code> directive with the same name. The previous definition is lost. Macro names respond to <code>#ifdef</code>, <code>#ifndef</code>, and <code>#undef</code> directives. See <a href="r3_3.html#r3_3_2_6_2">The #ifdef and #ifndef Directives</a> and <a href="r3_3.html#r3_3_2_2_4">Destroying Identifiers with #undef</a>.</p>
</div>
<a name="r3_3_2_8_2"></a>
<div class="content-level-h5" contains="Invoking Macros" id="r3_3_2_8_2">
<h5>3.3.2.8.2 Invoking Macros</h5>
<p>You invoke the macro by specifying the macro name followed by a list of zero or more actual parameters enclosed in parentheses and separated by commas. The number of actual parameters must match the number of formal parameters in the definition. The parentheses are required even if no parameters are specified. The syntax is:</p>
<pre>
MACRO_INVOCATION:
MACRO_IDENTIFIER ( [ACTUAL_PARAM] [, ACTUAL_PARAM]... )
ACTUAL_PARAM:
IDENTIFIER | RVALUE
</pre>
<p>An <em>RVALUE</em> is any value that can legally appear to the right of an equals sign in a <code>#declare</code> or <code>#local</code> declaration. See <a href="r3_3.html#r3_3_2_2_1">Declaring identifiers</a> for information on <em> RVALUE</em>.
When the macro is invoked, a new local symbol table is created. The actual parameters are assigned to formal parameter identifiers as local, temporary variables. POV-Ray jumps to the body of the macro and continues parsing until the matching <code>#end</code> directive is reached. There, the local variables created by the parameters are destroyed as well as any local
identifiers expressly created in the body of the macro. It then resumes parsing at the point where the macro was invoked. It is as though the body of the macro was cut and pasted into the scene at the point where the macro was invoked.</p>
<p class="Note"><strong>Note:</strong> It is possible to invoke a macro that was declared in another file. This is quite normal and in fact is how many <em>plug-ins</em> work (such as the popular Lens Flare macro). However, be aware that calling a macro that was declared in a file different from the one that it is being called from involves more overhead than calling one in the same file.</p>
<p>This is because POV-Ray does not tokenize and store its language. Calling a macro in another file therefore requires that the other file be opened and closed for each call. Normally, this overhead is inconsequential; however, if you are calling the macro many thousands of times, it can cause significant delays. A future version of the POV-Ray language will remove this problem.</p>
<p>Here is a simple macro that creates a window frame object when you specify the inner and outer dimensions.</p>
<pre>
#macro Make_Frame(OuterWidth,OuterHeight,InnerWidth,
InnerHeight,Depth)
#local Horz = (OuterHeight-InnerHeight)/2;
#local Vert = (OuterWidth-InnerWidth)/2;
difference {
box {
<0,0,0>,<OuterWidth,OuterHeight,Depth>
}
box {
<Vert,Horz,-0.1>,
<OuterWidth-Vert,OuterHeight-Horz,Depth+0.1>
}
}
#end
Make_Frame(8,10,7,9,1) //invoke the macro
</pre>
<p>In this example, the macro has five float parameters. The actual parameters (the values 8, 10, 7, 9, and 1) are assigned to the five identifiers in the <code>#macro</code> formal parameter list. It is as though you had used the following five lines of code.</p>
<pre>
#local OuterWidth = 8;
#local OuterHeight = 10;
#local InnerWidth, = 7;
#local InnerHeight = 9;
#local Depth = 1;
</pre>
<p>These five identifiers are stored in the same symbol table as any other local identifier such as <code>Horz</code> or <code>Vert</code> in this example. The parameters and local variables are all destroyed when the <code>#end</code> statement is reached. See <a href="r3_3.html#r3_3_2_2_3">Identifier Name Collisions</a> for a detailed discussion of how local identifiers, parameters, and global identifiers work when a local identifier has the same name as a previously declared identifier.</p>
</div>
<a name="r3_3_2_8_3"></a>
<div class="content-level-h5" contains="Are POV-Ray Macros a Function or a Macro?" id="r3_3_2_8_3">
<h5>3.3.2.8.3 Are POV-Ray Macros a Function or a Macro?</h5>
<p>POV-Ray macros are a strange mix of macros and functions. In traditional
computer programming languages, a macro works entirely by token substitution.
The body of the routine is inserted into the invocation point by simply
copying the tokens and parsing them as if they had been cut and pasted in
place. Such cut-and-paste substitution is often called <em>macro
substitution</em> because it is what macros are all about. In this respect,
POV-Ray macros are exactly like traditional macros in that they use macro
substitution for the body of the macro. However traditional macros also use
this cut-and-paste substitution strategy for parameters but POV-Ray does
not.</p>
<p>
Suppose you have a macro in the C programming language <code>
Typical_Cmac(Param)</code> and you invoke it as <code>Typical_Cmac(else
A=B)</code>. Anywhere that <code>Param</code> appears in the macro body, the
four tokens <code>else</code>, <code>A</code>, <code>=</code>, and <code>
B</code> are substituted into the program code using a cut-and-paste
operation. No type checking is performed because anything is legal. The
ability to pass an arbitrary group of tokens via a macro parameter is a
powerful (and sadly often abused) feature of traditional macros.</p>
<p>
After careful deliberation, we have decided against this type of parameters
for our macros. The reason is that POV-Ray uses commas more frequently in its
syntax than do most programming languages. Suppose you create a macro that is
designed to operate on one vector and two floats. It might be defined <code>
OurMac(V,F1,F2)</code>. If you allow arbitrary strings of tokens and invoke a
macro such as <code>OurMac(<1,2,3>,4,5)</code> then it is impossible to
tell if this is a vector and two floats or if its 5 parameters with the two
tokens <code><</code> and <code>1</code> as the first parameter. If we
design the macro to accept 5 parameters then we cannot invoke it like this...
<code>OurMac(MyVector,4,5)</code>.</p>
<p>
Function parameters in traditional programming languages do not use token
substitution to pass values. They create temporary, local variables to store
parameters that are either constant values or identifier references which are
in effect a pointer to a variable. POV-Ray macros use this function-like
system for passing parameters to its macros. In our example <code>
OurMac(<1,2,3>,4,5)</code>, POV-Ray sees the <code><</code> and
knows it must be the start of a vector. It parses the whole vector expression
and assigns it to the first parameter exactly as though you had used the
statement <code>#local V=<1,2,3>;</code>.</p>
<p>
Although we say that POV-Ray parameters are more like traditional function
parameters than macro parameters, there still is one difference. Most
languages require you to declare the type of each parameter in the definition
before you use it but POV-Ray does not. This should be no surprise because
most languages require you to declare the type of any identifier before you
use it but POV-Ray does not. This means that if you pass the wrong type value
in a POV-Ray macro parameter, it may not generate an error until you
reference the identifier in the macro body. No type checking is performed as
the parameter is passed. So in this very limited respect, POV-Ray parameters
are somewhat macro-like but are mostly function-like.</p>
</div>
<a name="r3_3_2_8_4"></a>
<div class="content-level-h5" contains="Returning a Value Like a Function" id="r3_3_2_8_4">
<h5>3.3.2.8.4 Returning a Value Like a Function</h5>
<p>POV-Ray macros have a variety of uses. Like most macros, they provide a
parameterized way to insert arbitrary code into a scene file. However most
POV-Ray macros will be used like functions or procedures in a traditional
programming language. Macros are designed to fill all
of these roles.</p>
<p>
When the body of a macro consists of statements that create an entire item
such as an object, texture, etc. then the macro acts like a function which
returns a single value. The <code>Make_Frame</code> macro example in the
section <a href="r3_3.html#r3_3_2_8_2">Invoking Macros</a> above is such a macro which returns a
value that is an object. Here are some examples of how you might invoke
it.</p>
<pre>
union { //make a union of two objects
object{ Make_Frame(8,10,7,9,1) translate 20*x}
object{ Make_Frame(8,10,7,9,1) translate -20*x}
}
#declare BigFrame = object{ Make_Frame(8,10,7,9,1)}
#declare SmallFrame = object{ Make_Frame(5,4,4,3,0.5)}
</pre>
<p>Because no type checking is performed on parameters and because the
expression syntax for floats, vectors, and colors is identical, you can
create clever macros which work on all three. See the sample scene <code>
MACRO3.POV</code> which includes this macro to interpolate values.</p>
<pre>
// Define the macro. Parameters are:
// T: Middle value of time
// T1: Initial time
// T2: Final time
// P1: Initial position (may be float, vector or color)
// P2: Final position (may be float, vector or color)
// Result is a value between P1 and P2 in the same proportion
// as T is between T1 and T2.
#macro Interpolate(T,T1,T2,P1,P2)
(P1+(T1+T/(T2-T1))*(P2-P1))
#end
</pre>
<p>You might invoke it with <code>P1</code> and <code>P2</code> as floats,
vectors, or colors as follows.</p>
<pre>
sphere{
Interpolate(I,0,15,<2,3,4>,<9,8,7>), //center location is vector
Interpolate(I,0,15,3.0,5.5) //radius is float
pigment {
color Interpolate(I,0,15,rgb<1,1,0>,rgb<0,1,1>)
}
}
</pre>
<p>As the float value <code>I</code> varies from 0 to 15, the location,
radius, and color of the sphere vary accordingly.</p>
<p>
There is a danger in using macros as functions. In a traditional programming
language function, the result to be returned is actually assigned to a
temporary variable and the invoking code treats it as a variable of a given
type. However macro substitution may result in invalid or undesired syntax.
The definition of the macro <code>Interpolate</code> above has an
outermost set of parentheses. If those parentheses are omitted, it will not
matter in the examples above, but what if you do this...</p>
<pre>
#declare Value = Interpolate(I,0,15,3.0,5.5)*15;
</pre>
<p>The end result is as if you had done...</p>
<pre>
#declare Value = P1+(T1+T/(T2-T1))*(P2-P1) * 15;
</pre>
<p>which is syntactically legal but not mathematically correct because the
<code>P1</code> term is not multiplied. The parentheses in the original
example solves this problem. The end result is as if you had done...</p>
<pre>
#declare Value = (P1+(T1+T/(T2-T1))*(P2-P1)) * 15;
</pre>
<p>which is correct.</p>
</div>
<a name="r3_3_2_8_5"></a>
<div class="content-level-h5" contains="Returning Values Via Parameters" id="r3_3_2_8_5">
<h5>3.3.2.8.5 Returning Values Via Parameters</h5>
<p>Sometimes it is necessary to have a macro return more than one value or
you may simply prefer to return a value via a parameter as is typical in
traditional programming language procedures. POV-Ray macros are capable of
returning values this way. The syntax for POV-Ray macro parameters says that
the actual parameter may be an <em>IDENTIFIER</em> or an <em> RVALUE</em>.
Values may only be returned via a parameter if the parameter is an <em>
IDENTIFIER</em>. Parameters that are <em>RVALUES</em> are constant values
that cannot return information. An <em>RVALUE</em> is anything that legally
may appear to the right of an equals sign in a <code>#declare</code> or
<code>#local</code> directive. For example consider the following trivial
macro which rotates an object about the x-axis.</p>
<pre>
#macro Turn_Me(Stuff,Degrees)
#declare Stuff = object{Stuff rotate x*Degrees}
#end
</pre>
<p>This attempts to re-declare the identifier <code>Stuff</code> as the
rotated version of the object. However the macro might be invoked with <code>
Turn_Me(box{0,1},30)</code> which uses a box object as an <em> RVALUE</em>
parameter. This will not work because the box is not an identifier. You can
however do this</p>
<pre>
#declare MyObject=box{0,1}
Turn_Me(MyObject,30)
</pre>
<p>The identifier <code>MyObject</code> now contains the rotated box.</p>
<p>
See <a href="r3_3.html#r3_3_2_2_3">Identifier Name Collisions</a> for a detailed discussion of how
local identifiers, parameters, and global identifiers work when a local
identifier has the same name as a previously declared identifier.</p>
<p>
While it is obvious that <code>MyObject</code> is an identifier and <code>
box{0,1}</code> is not, it should be noted that <code>
Turn_Me(object{MyObject},30)</code> will not work because <code>
object{MyObject}</code> is considered an object statement and is not a <em>
pure</em> identifier. This mistake is more likely to be made with float
identifiers versus float expressions. Consider these examples.</p>
<pre>
#declare Value=5.0;
MyMacro(Value) //MyMacro can change the value of Value but...
MyMacro(+Value) //This version and the rest are not lone
MyMacro(Value+0.0) // identifiers. They are float expressions
MyMacro(Value*1.0) // which cannot be changed.
</pre>
<p>Although all four invocations of <code>MyMacro</code> are passed the value
5.0, only the first may modify the value of the identifier.</p></div>
</div>
</div>
</body>
</html>
|