Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mayavi, clip planes #1269

Open
priisdk opened this issue Aug 6, 2023 · 0 comments
Open

Mayavi, clip planes #1269

priisdk opened this issue Aug 6, 2023 · 0 comments

Comments

@priisdk
Copy link

priisdk commented Aug 6, 2023

In the program below I try to put a section of the earth (ocean), a tower (of a wind turbine) at origo, and the Sun.
My final goal is to animate the sunset as seen from some hundred meters behind the tower - and with the real curvature of the Earth.

When zooming in the nearest objects seem to disappear too early - as if there was a 'near clip plane' (WebGL term).
In the actual program I have put the Sun too near the Earth because if I put the Sun at its real position (units in meters) I cannot see the objects in the foreground at all.

Is there any way to make it better?
If I am right about the 'near clip plane' is there any way to modify the position of that plane (and eventually also a 'far clip plane')?

Poul Riis
Denmark

import numpy as np
from mayavi.mlab import *
from math import *
from matplotlib.colors import hsv_to_rgb

onemillion=1000000
unit=1000000 # sizes and distances well be in meters if unit is set to one million
rsun=150000unit
Rsun=700
unit
Rearth=20unit/pi
dmax=Rearth/100
phimax=atan2(dmax,Rearth)
htower=300/onemillion
unit
rtower=3/onemillion*unit

def cylinder(pos,axis,radius,length):
pi = np.pi
twopi=2*pi
cos = np.cos
sin = np.sin
dphi, dh = pi / 250.0, 0.1
[phi, z] = np.mgrid[0:pi + dphi * 1.5:dphi,
0:length:dh]
ex=[1,0,0]
normaxis=sqrt(axis[0]**2+axis[1]**2+axis[2]*2)
ez=[axis[0]/normaxis,axis[1]/normaxis,axis[2]/normaxis]
ey=[0,-ez[2],ez[1]]
x = pos[0]+radius
(cos(phi)ex[0]+sin(phi)ey[0])+zez[0]
y = pos[1]+radius
(cos(phi)ex[1]+sin(phi)ey[1])+zez[1]
z = pos[2]+radius
(cos(phi)*ex[2]+sin(phi)ey[2])+zez[2]
return mesh(x, y, z, colormap="copper")

def calot(pos,axis,radius,deltatheta):
pi = np.pi
twopi=2pi
cos = np.cos
sin = np.sin
dphi, dtheta = pi / 250.0, deltatheta/250.0
[phi, theta] = np.mgrid[0:twopi + dphi * 1.0:dphi,0:deltatheta:dtheta]
ex=[1,0,0]
normaxis=sqrt(axis[0]**2+axis[1]**2+axis[2]**2)
ez=[axis[0]/normaxis,axis[1]/normaxis,axis[2]/normaxis]
ey=[0,-ez[2],ez[1]]
x = pos[0]+radius
sin(theta)*(cos(phi)ex[0]+sin(phi)ey[0])+radiuscos(theta)ez[0]
y = pos[1]+radius
sin(theta)
(cos(phi)ex[1]+sin(phi)ey[1])+radiuscos(theta)ez[1]
z = pos[2]+radius
sin(theta)
(cos(phi)*ex[2]+sin(phi)ey[2])+radiuscos(theta)*ez[2]
return mesh(x, y, z,color=(0,0,1))

figure(size=(1200,1000))
cylinder([0,0,0],[0,0,1],rtower,htower)
rgb1=hsv_to_rgb((0.2,0.7,1))
xaxis=quiver3d(0, 0, 0, 1000,0,0, line_width=2, scale_factor=1)
yaxis=quiver3d(0, 0, 0, 0,1000,0, line_width=2, scale_factor=1)
calot([0,0,-6366000/100],[0,0,1],6366000/100,pi/180/2*10)
points3d(-0,-1500000,1000,7000,resolution=256,scale_factor=1,color=(rgb1[0],rgb1[1],rgb1[2]))
hsv_to_rgb((0.2,0.7,1))
view(90, 89, 5000,(0,0,0))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant