3
$\begingroup$

Attached is a diagram and a picture of my current model and a GIF image what I'm trying to achieve.

Sketch:

diagram of what I'm trying to achieve

Screenshot:

enter image description here

Details:

The inner circle is a perfect sphere with a radius of 6.63

The outer circle the bottom half is from a perfect sphere with a radius of 12. The top half had a radius of 12 as well but was reduced 90% in the Z direction. This is to simulate how an eye is not perfectly spherical.

Gif Image Showing My Goal:

Gif Image Showing My Goal

The image above shows me taking the inner sphere and raising it out of the other sphere. This will create the 'cornea' of the eye I plan on modeling later. I can then use the modifier boolean to union them together at a later time.

The Question:

I'm doing this for 3D Printing and medical purposes so the dimensions need to be exact. How do I raise the inner sphere so that it will intersect the other sphere and create a 12 distance once it's outside. In the GIF image I uploaded you can see I was off in my attempt to raise it and I only guessed with a measuring tool what created the 12 distance.

Put another way the points where the circumference of the inner circle touch the circumference of the outer circle should create a distance of 12. In my diagram it's the dashed line that says 12.

What is the best way to go about this so it's pixel perfect? (as much as possible)

$\endgroup$
5
  • 1
    $\begingroup$ planetcalc.com/1421 $\endgroup$
    – susu
    Commented Jul 3, 2020 at 6:21
  • 1
    $\begingroup$ Good find, I'm starting to think this may be more of a math problem then blender issue possibly. $\endgroup$ Commented Jul 3, 2020 at 6:53
  • 1
    $\begingroup$ Indeed, the issue is not about the tools but having the concept clear. $\endgroup$
    – susu
    Commented Jul 3, 2020 at 6:56
  • 1
    $\begingroup$ Good thing I'm a math major... Place the center of the small sphere at 6.53228. I'll write up a proper answer in a few minutes. $\endgroup$
    – Ron Jensen
    Commented Jul 3, 2020 at 7:05
  • $\begingroup$ Yeah you are right that is the right answer :). I got 6.57 as the answer that seems to work and create exactly 12 which is very close to yours. I just did it by manually moving for now but curious the exact way to do it. $\endgroup$ Commented Jul 3, 2020 at 7:40

2 Answers 2

6
$\begingroup$

We'll start with the 12 mm radius sphere, note the 12mm chord is in the XY plane, so scaling on the Z axis won't change its size, it will only move the position in the Z direction. Because we can draw a right triangle with hypotenuse 12 (the radius) and leg 6 (half the chord length) we know the remaining side is $6\sqrt{3}$. When we squish the sphere by 90% that side will also squish, so the red dot winds up at $0.9 \cdot 6\sqrt{3}$

The 12 mm sphere

Moving onto the smaller, 6.63 mm sphere, we can again draw a right triangle, this time with hypotenuse 6.63 but still with a leg of 6. We need to resort to the distance formula $ k = \sqrt{6.63^2 - 6^2} $ to find the side length because this triangle wasn't special like the last one.

The 6.63 mm Sphere

To position the red dots on top of each other, we need to move the green dot so it is in the right place below the red dot: $ \textrm{green dot} = 0.9 \cdot 6\sqrt{3} - \sqrt{6.63^2 - 6^2} $

Final ResultThe final result.

$\endgroup$
1
  • 3
    $\begingroup$ Hi Ron! Welcome to the community. A nice and precise answer. Nothing unnecessarry, straight to the point. I like it! $\endgroup$
    – Teck-freak
    Commented Jul 3, 2020 at 8:42
3
$\begingroup$

Bmesh version

enter image description here

Make a radius 1 eyeball with a 0.5 radius aperture to fit a 0.5525 radius cornea. _ie to get question dimensions scale by 12.

As per question eye faces in Z direction blender usually uses -Y to face camera in front view

eye_angle is the angle above horizontal to cut aperture.

cornea_angle is half angle of opening

Create a vert at back of eye (0, 0, -1) and spin it around 90 + eye_angle degrees.

Scale any vertex coordinates in "front half of eye by front_half_scale

The last created vert will be on the aperture. It will have a z coordinate where to place the cornea lens

Similarly get the angle that the aperture latitude will be for the smaller cornea placed at origin, drop it such that chord is at zero then move up to place lens over eye hole.

enter image description hereI

Image shows on left the edges created before the final full spin around Z. As commented in code, could skip last step and instead use as a profile to revolve via the screw modifier

Could also be done via the make maths surface by defining the equation scribing based on our ruleset

Test code,

import bpy
import bmesh
from math import radians, acos, asin, sin, cos

context = bpy.context
coll = context.collection


# inputs
#####################################
aperture = 0.5
front_half_scale = 0.9
cornea_radius = 0.5525 # 6.63 / 12
#####################################

eye_angle = acos(aperture)
cornea_angle = asin(aperture / cornea_radius)

bm = bmesh.new()
vs = bm.verts.new((0, 0, -1))
bmesh.ops.spin(
        bm,
        geom=[vs],
        axis=(0, -1, 0),
        angle=radians(90) + eye_angle,
        steps=16,
        )
bmesh.ops.scale(
        bm, 
        verts=[v for v in bm.verts if v.co.z > 0],
        vec=(1, 1, front_half_scale),
        )

bm.verts.ensure_lookup_table()
vc = bm.verts[-1]
vc.select_set(True)

bmesh.ops.spin(
        bm,
        geom=[vc],
        angle=cornea_angle,
        axis=(0, -1, 0),
        cent=(0, 0, vc.co.z - cornea_radius * cos(cornea_angle)),
        steps=8,  
        )      


# remove this and use screw modifier instead        
bmesh.ops.spin(
        bm,
        geom=bm.verts[:] + bm.edges[:],
        angle=radians(360),
        axis=(0, 0, 1),
        steps=32,
        use_merge=True,
        )
        
bmesh.ops.remove_doubles(
        bm,
        verts=bm.verts,
        dist=1e-5,
        )   

me = bpy.data.meshes.new("Eye")
bm.to_mesh(me)
ob = bpy.data.objects.new("Eye", me)
coll.objects.link(ob)

Note: This should drop pretty simply into the addon add mesh object template in text editor.

Related:

https://blender.stackexchange.com/a/133880/15543

$\endgroup$
2
  • $\begingroup$ Very nice! I noticed it has a bunch of unwelded verts, though. Perhaps a call to bmesh.ops.remove_doubles after the final spin? $\endgroup$
    – Ron Jensen
    Commented Jul 3, 2020 at 13:16
  • 2
    $\begingroup$ Thanks Ron for the reminder.. Was considering leaving the lens separate and noticed that use merge in the spin modifier ignores the poles. Put it back in to demonstrate (and stitch the seam)... and the remove doubles to remove extra poles. Lover of maths too (was my major too.. last century) Look forward to more "mathsy" answers in the future. $\endgroup$
    – batFINGER
    Commented Jul 3, 2020 at 13:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .