Take a look at this Eye !!!

Unlike `mesh(spheremesh)`

method, current `surface(x,y,z)`

method leaves a **circular hole** at the **north pole** of the ball, see:

and sometimes leave an **1. circular hole / 2. irregular hole** composed of several **black triangular faces** at the **south pole** as well, see:

- How to Create a 3D-Transparent Cylinder with GLMakie or Plots if possible?
- Drawing an ellipsoid to visualize a tensor - #11 by AndiMD

a MWE would be

```
# https://discourse.julialang.org/t/how-to-get-a-semi-transparent-sphere-in-makie/117944/2?u=xczphysics
using Colors, GeometryBasics #versions 0.10.5, 0.12.11, 0.9.20
using GLMakie
GLMakie.activate!()
# A sphere
n = 13
function gan_sphere_points(num, Θ_L, Θ_R)
r = 1.0f0
Θ = range(Θ_L, Θ_R, num)
Φ = range(-π, π, num)
x = [r * sin(θ) * cos(ϕ) for ϕ in Φ, θ in Θ] # 这里的 ϕ,θ 顺序会影响 可否穿透球表面获取位置
y = [r * sin(θ) * sin(ϕ) for ϕ in Φ, θ in Θ]
z = [r * cos(θ) for ϕ in Φ, θ in Θ]
# return [x, y, z]
# 应用旋转变换
rotation_angle = -π/3 # 45度
rotation_matrix = [cos(rotation_angle) 0 -sin(rotation_angle);
0 1 0;
sin(rotation_angle) 0 cos(rotation_angle)]
x_rotated = rotation_matrix[1,1] .* x + rotation_matrix[1,3] .* z
y_rotated = y
z_rotated = rotation_matrix[3,1] .* x + rotation_matrix[3,3] .* z
return [x_rotated, y_rotated, z_rotated]
end
sphere_points = gan_sphere_points(n, 0, π)
fig, ax, p = GLMakie.surface(sphere_points...,
color=sphere_points[3], invert_normals=true, transparency=true)
fig
```

If your ultimate goal is to simply show a Sphere or Ellipsoid after rotations, take a look at Meshes.jl. In particular, you can

```
using Meshes
import GLMakie as Mke
ellipsoid = Ellipsoid(...)
viz(ellipsoid)
```

You can further rotate the ellipsoid with the `Rotate`

transform:

```
ellipsoid |> Rotate(...) |> viz
```

You need both triangles and quadrangles to properly discretize the sphere/ellipsoid. The `Makie.surface`

displays meshes that are made of quadrangles.

1 Like

**Thanks for your kind hint!** During my testing,

this rotates correctly:

```
using Meshes, Rotations, GLMakie
Ellipsoid((3., 2., 1.), (0., 0., 0.), RotXYZ(π/4, π/5, π/3)) |> viz
```

but the following doesn’t even rotate:

```
using Meshes, Rotations, GLMakie
Ellipsoid((3., 2., 1.)) |> Rotate(RotXYZ(π/4, π/5, π/3)) |> viz
```

for what? args works, while the operator fails to work…

Can you please try to call `discretize`

before `viz`

? This will force the discretization of the `Ellipsoid`

into a mesh. If it works, then this is an issue on our side. I am far from my computer now.

1 Like

it works

```
using Meshes, Rotations, GLMakie
discretize(Ellipsoid((3., 2., 1.)), RegularDiscretization(10,10)) |> Rotate(RotXYZ(π/4, π/5, π/3)) |> viz
```

and the kwarg `color = 1:nelements(mesh)`

of the method `viz`

seems to need `discretize(mesh)`

first too:

```
using Meshes, Rotations, GLMakie
ellipsoid = Ellipsoid((3., 2., 1.), (0., 0., 0.), RotXYZ(π/4, π/5, π/3))
ellipsoid = discretize(ellipsoid, RegularDiscretization(10,10))
viz(ellipsoid, color = 1:nelements(ellipsoid), showsegments = true)
```

1 Like

Fyi, starting/ending the polar angles at a small delta from the poles (instead of the `0`

and `pi`

endpoints) allows us to fill the holes as much as we like.

```
δ = 1e-6
sphere_points = gan_sphere_points(n, δ, π-δ)
```

Of course we also need to increase `n`

to make the sphere smooth and round.

1 Like

Nice that it works. So the `Rotate`

doesn’t change the visualization? Mind opening an issue in Meshes.jl so that we can take a look over the week?

1 Like

OOObservant and SSSmart !!!

Compared to **the ***x,y* coordinate of the eye’s pupil always = 0,0 (when the sphere is not rotated), I had also found **the ***x,y* coordinate of the “ass” → 0,0 but mostly ≠ 0,0 may be the reason why the “ass” sew itself, but never took a closer look into it…

Thanks bro, this is a beautiful shortcut.

The solution to this problem should be gifted to you.

Glad it helped. I am not sure if I totally followed your description, but as Émile Zola once said, the celestial sphere and the ass are two great levers.

2 Likes