Changing the angle / curvature of a mesh created using python and parametric equations

147 Views Asked by At

Changing the angle / curvature of a mesh created using python and parametric equations.

I can create a Hyperboloid using Python and parametric equations

img1

Python script formula snippet:

for i in range (0, num_x):
        for j in range(0,num_y):
            # nomalize range
                    
            u = 8*(i/num_x-1/2)
            v = 2*math.pi*(j/(num_y-1)-1/2)
            
            x = math.sqrt(1+u**2)*math.cos(v)*uval_a/2
            y = math.sqrt(1+u**2)*math.sin(v)*uval_a/2
            z = uval_b*(u)/(2*math.pi/1)
            # uval_a changes the diameter of center hole
            # uval_b changes the height
            
  
            vert = (x,y,z)
            verts.append(vert)

My goal is to create a mesh which curves left and curves right using Python and Parametric Equations, similar to the image below.

img2

I want to say that the issue is with the U and V variables but I'm not exactly sure how to change these to cause those types of curvatures in the mesh.

1

There are 1 best solutions below

0
On

This is not Python, but Mathematica... Not what you wanted but it is another example exercise to see how the parameters are written differently or how their domain limits are set.

ParametricPlot3D[{(4 - Sqrt[2 + u^2]) Cos[
    u - v], (4 - Sqrt[2 + u^2]) Sin[u - v], (u + v)^2}, {u, -1, 
  1}, {v, -2, 2}, Boxed -> False, Axes -> None]
ParametricPlot3D[{Sqrt[1 + u^2] Cos[v], Sqrt[1 + u^2] Sin[v], 
  u}, {u, -4, 4}, {v, -Pi, Pi}, Boxed -> False, Axes -> None]

enter image description here