1

Sigh! I wish this worked:

// Spline Sine
#declare SphereSine = union {
    #local Radius = 0.15;
    #local Amplitude = 2;
    #local Iterator = 0;
    #local Amount = 20;
    sphere_sweep {
        b_spline
        Amount,

        #for (Iterator, 0, Amount, 1)
            <Iterator, sin(Iterator)*Amplitude, 0>, Radius
        #end

        tolerance 0.1
        pigment {
            rgb <1, 0, 0>
        }
    }
}

Are there any ways to automate the adding of points to a spline in POV-Ray, so I don't have to add the points manually? Are there other alternatives?

Kebman
  • 1,901
  • 1
  • 20
  • 32

2 Answers2

1

You can write a macro of your own to wrap the for loop in and reduce the code to a single line of, say, points(0.15, 2, 20);. Otherwise, if you are looking for something like a built-in keyword for specifying the number of points or a point generation function, I'm afraid that there are no options available out of the box.

Vadim Landa
  • 2,784
  • 5
  • 23
  • 33
1

sorry been too late ...

the problem is that you have put an amount of 20 but inside loop there are 21 values (0 to 20).

your solution really works ! just change

#for (Iterator, 0, Amount, 1)

with

#for (Iterator, 0, Amount-1, 1)

Nome
  • 11
  • 3
  • Hello! Welcome to Stackoverflow. Please consider using the Stackoverflow Markdown for code. See https://stackoverflow.com/editing-help for more information – Mike Elahi Nov 11 '22 at 11:56
  • It's a few years ago now, but I distinctly remember this way of coding POV-Ray not working. Have you tested this pattern? – Kebman Nov 18 '22 at 15:29
  • Kebman, do you refer to "#for (Iterator, 0, Amount-1, 1)" ? it works in pov-Ray, sure. Mike, I'll look Stackoverflow Markdown, thanks! – Nome Jun 02 '23 at 12:20