2
$\begingroup$

In Carrara 4.0 Pro, I am able to create various modeling objects using math. The UI comes with 4 sliders (p1, p2, p3, p4), with values varying from -1 to +1 or -pi to +pi, and a text area for the logic loops that describe the formula, similar to the following:

r2=20*p1;
r1=10*p2;
t=2*PI*u;
p=PI*(v-0.5);
x=r1*cos(t)*cos(p);
y=r1*sin(t)*cos(p);
z=r1*sin(p);
x=x+r2*cos(t);
y=y+r2*sin(t);

So something like this would be nice to have, in Blender, as well.

$\endgroup$
5
$\begingroup$

There's a Mesh Function add-on:

enter image description here

generates a UI for making parametric surfaces:

enter image description here


Or use Sverchok's scripted node. This may be more complicated at first but allows a lot of customization.

import math
from math import pi as PI
from math import cos, sin

def sv_main(p1=0.3, p2=0.7, vdivs=20, points=200):
    verts_out = []

    in_sockets = [
        ['s', 'p1', p1],
        ['s', 'p2', p2],
        ['s', 'vdivs', vdivs],
        ['s', 'points', points]
    ]

    r2=20*p1
    r1=10*p2
    theta = 1/points
    vtheta = 1/vdivs

    for v in range(vdivs):
        v_points = []
        for i in range(points):
            t = 2 * PI * (theta * i)
            p = PI * ((vtheta*v) - 0.5)
            x = r1 * cos(t) * cos(p)
            y = r1 * sin(t) * cos(p)
            z = r1 * sin(p)
            x = x + r2 * cos(t)
            y = y + r2 * sin(t)
            v_points.append([x,y,z])

        verts_out.append(v_points)

    out_sockets = [
        ['v', 'verts', [verts_out]]
    ]

    return in_sockets, out_sockets

enter image description here

Because the script makes a nested list of each V ring of verts, the UV Connection node can make the appropriate "UV edge-surf".

For help with Sverchok in general see the documentation.
For help with Scripted Node specifically first have a look at the dedicated document about it

$\endgroup$
  • $\begingroup$ May I ask, what skin/theme are you using? $\endgroup$ – angussidney May 18 '16 at 9:48
  • $\begingroup$ @angussidney Flatty Light, is included by default in Themes :) but I have modified the 3dview background to be lighter. $\endgroup$ – zeffii May 18 '16 at 10:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.