0
$\begingroup$

How can I calculate a 28.5 mm hole for a hyperboloid center opening when it's Z is equal to 0

The arrows point to where z=0 and the 28.5mm hole should be. (I know I could scale the object but I need to use the formula to animate other values)

I'm using animation nodes and python to animate it see attached file

image

import bpy
import math

def parametricfunc(uval_a, uval_b, zaxis_a, zaxis_b, num_x, num_y):
    
    
    # mesh arrays
    verts = []
    faces = []

    # mesh variables
    #num_x = 40
    #num_y = 40
    
    pi = math.pi
    PHI = (1+math.sqrt(5))/2 #1.61803398874989
    phi = (1+math.sqrt(5))/2-1 #0.61803398874989
    rmse_PHI = PHI * math.sqrt(0.5) # 0.707*PHI =1.144
    rmse_phi = phi * math.sqrt(0.5) # 0.707*phi
    golden_angle_rad = pi*(3-math.sqrt(5)) #2.39996322972865
    golden_angle_deg_sm = math.degrees(golden_angle_rad)  # 137.507764050038
    golden_angle_deg_bg = 360-golden_angle_deg_sm #222.492235949962

    #print("type ux=%s" % (type(frame)))
    
    # fill verts array
    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 = 2*math.sqrt(1+u*u)*math.cos(v)*(uval_a/12)
            y = 2*math.sqrt(1+u*u)*math.sin(v)*(uval_a/12)
            z = uval_b*(u)
            
            vert = (x,y,z)
            verts.append(vert)

    #print("type verts=%s" % (type(vert)))

    # fill faces array
    count = 0
    for i in range (0, num_y *(num_x-1)):
        if count < num_y-1:
            A = i
            B = i+1
            C = (i+num_y)+1
            D = (i+num_y)
            face = (A,B,C,D)
            faces.append(face)
            count = count + 1
        else:
            count = 0
            
        
        edges = AN.algorithms.mesh_generation.grid.quadEdges(num_x, num_y)
        polys = AN.algorithms.mesh_generation.grid.quadPolygons(num_x, num_y)
    return x, y, z, verts, A, B, C, D, faces, edges, polys
            
x, y, z, verts, A, B, C, D, faces, edges, polys  = parametricfunc(uval_a, uval_b, zaxis_a, zaxis_b, num_x, num_y)   

$\endgroup$
11
  • $\begingroup$ Could you explain a bit more why you're calculating it like that? Do you want to change the algorithm or to find the good input values? $\endgroup$
    – lemon
    Oct 17 '20 at 8:07
  • $\begingroup$ In general you need to find the local minimum of your hyperbola function, which correlates to a certain z (or j) in your case. Lots of examples online. Make sure the function actually places a vertex at that position. $\endgroup$ Oct 17 '20 at 8:16
  • $\begingroup$ @lemon I needed to use the parametric equation it allows for easier animation values (x,y,z) with animation nodes and python mathworld.wolfram.com/One-SheetedHyperboloid.html $\endgroup$
    – Rick T
    Oct 17 '20 at 8:37
  • 1
    $\begingroup$ Or parametric for this hyperbola part: x = a * sqrt(1 + u**2) and z = c * u. $\endgroup$
    – lemon
    Oct 17 '20 at 9:02
  • 1
    $\begingroup$ ok, have added an answer considering the diameter as input. => uval_a / 2 $\endgroup$
    – lemon
    Oct 17 '20 at 9:30
3
$\begingroup$

If you want to input the radius here:

enter image description here

You can change your code by:

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*u)*math.cos(v)*uval_a/2
        y = math.sqrt(1+u*u)*math.sin(v)*uval_a/2
        z = uval_b*u
        
        vert = (x,y,z)
        verts.append(vert)

As explained here

The base equation is:

$$ \frac{x^2}{a^2} - \frac{y^2}{b^2} = 1 $$

Which gives:

$$ y = \pm \frac{b}{a} \sqrt{x^2 - a^2} $$

When a and b are defined by:

enter image description here

$\endgroup$

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.