在两个向量 vpython 之间创建一个角度?
Create an angle between two vectors vpython?
我正在尝试使用 vpython 在两个向量之间创建一个角度符号。这些向量是源向量和该向量的 x-y 投影。我正在使用 vpython 包,特别是来自 vpython 的 shapes
模块的 arc
。
from vpython import *
import numpy as nump
scene2 = canvas(title='Source Vector',
width=800, height=600,
center=vector(0,0,0), background=color.white)
scene2.select()
geophone = pyramid(pos=vector(0,0,0), size=vector(2,2,2),
color = color.green, up = vector(-1,0,0))
shot_loc = sphere(pos=vector(-20,30,-20),
size=vector(2,2,2), color= color.red)
shot_loc_label = label(pos=shot_loc.pos,
text='Vib Shot', xoffset=-30,
yoffset=30, space=10,
height=12,
font='serif')
ray_vector = arrow(pos=vector(0,0,0), axis=shot_loc.pos,
shaftwidth=0.2, color= color.blue, length =40, headlength = 2, headwidth =1)
ray_vec_label = label(pos=(ray_vector.axis - ray_vector.pos)/2,
text='Ray Vector', xoffset=-30,
yoffset=30, space=10,
height=12,
font='sans')
source_vector = arrow(pos=vector(0,0,0), axis= vector(20,-30, 20),
shaftwidth=0.2, color= color.red, length =30, headlength = 2, headwidth =1)
projection_of_source_vector = cylinder(pos=vector(0,0,0), axis= vector(20,0, 20),
radius=0.2, color=color.green)
source_vec_label = label(pos=source_vector.axis,
text='Source Vector', xoffset=30,
yoffset=30, space=10,
height=12,
font='sans')
plunge_angle = diff_angle(vector(20,0, 20),vector(20,-30, 20))
plung_arc = shapes.circle(radius=10, angle1=0, angle2=plunge_angle, np=10, rotate=90)
extrusion(path=[vector(20,0, 20), vector(20,-30, 20)],
shape=plung_arc)
x_axis = arrow(pos=vector(-50,0,0), axis=vector(50,0,0), shaftwidth=0.2,
color= color.black, length =100, headlength = 2, headwidth =1)
z_axis = arrow(pos=vector(0,-40,0), axis=vector(0,40,0), shaftwidth=0.2,
color= color.black, length =80, headlength = 2, headwidth =1)
y_axis = arrow(pos=vector(0,0,40), axis=vector(0,0,-40), shaftwidth=0.2,
color= color.black, length =80, headlength = 3, headwidth =2)
T_x = text(text='X',
align='center', color=color.black, pos = vector(-52,0,0),
billboard =True, height =2)
T_y = text(text='Z',
align='center', color=color.black, pos = vector(0,-43,0),
billboard =True, height =2)
T_z = text(text='Y',
align='center', color=color.black, pos = vector(0,0, 43),
billboard =True, height =2)
T_x.width = 2*T_x.width
T_y.width = 2*T_y.width
T_z.width = 2*T_z.width
3d cartisian
终于自己搞定了。在 jupyter notebook 中编写的这段代码的结果如附图所示。我正在使用 vpython 新版本,它可以在 jupyter notebook 中 运行。
无法完成的一个是使用 Latex 编写 theta 和 alpha。
from vpython import *
import numpy as nump
scene2 = canvas(width=800, height=600,
center=vector(0,0,0), background=color.white)
scene2.select()
geophone = pyramid(pos=vector(0,0,0), size=vector(2,2,2),
color = color.green, up = vector(-1,0,0))
geophone_label = label(pos=geophone.pos,
text='Geophone', xoffset=-30,
yoffset=-20, space=10,
height=12,
font='sans')
shot_loc = sphere(pos=vector(-20,30,-20),
size=vector(2,2,2), color= color.red)
shot_loc_label = label(pos=shot_loc.pos,
text='Vib Shot', xoffset=-30,
yoffset=30, space=10,
height=12,
font='sans')
ray_vector = arrow(pos=vector(0,0,0), axis=shot_loc.pos,
shaftwidth=0.2, color= color.blue, length =40, headlength = 2,
headwidth =1)
ray_vec_label = label(pos=(ray_vector.axis - ray_vector.pos)/2,
text='Ray Vector', xoffset=-30,
yoffset=30, space=10,
height=12,
font='sans')
source_vector = arrow(pos=vector(0,0,0), axis= vector(20,-30, 20),
shaftwidth=0.2, color= color.red, length =30, headlength = 2,
headwidth =1)
projection_of_source_vector = cylinder(pos=vector(0,0,0), axis= vector(20,0, 20),
radius=0.2, color=color.green)
source_vec_label = label(pos=source_vector.axis,
text='Source Vector', xoffset=30,
yoffset=30, space=10,
height=12,
font='sans')
plunge_angle = diff_angle(vector(20,0, 20),vector(20,-30, 20))
plung_arc = shapes.arc(radius=10, angle1=0, angle2=-plunge_angle)
b = cross(vector(20,0, 20),vector(20,-30, 20))
norm_vector = norm(b)
extrusion(path=[vector(0,0, 0), norm_vector],
shape=plung_arc)
plunge_label = label(pos=vector(4,-4,4),
text='α', xoffset=30,
yoffset=-20, space=10,
height=12,
font='sans')
back_azimuth_angle = diff_angle(vector(20,0, 20),vector(0,0, -1))
back_azimuth_arc = shapes.arc(radius=10, angle1=0, angle2=back_azimuth_angle)
c = cross(vector(20,0, 20),vector(0,0, -1))
norm_vector_azimth = norm(c)
extrusion(path=[vector(0,0, 0), norm_vector_azimth],
shape=back_azimuth_arc)
azimuth_label = label(pos=vector(3,0,-2),
text='θ', xoffset=30,
yoffset=30, space=10,
height=12,
font='sans')
x_axis = arrow(pos=vector(-50,0,0), axis=vector(50,0,0), shaftwidth=0.2,
color= color.black, length =100, headlength = 2, headwidth =1)
z_axis = arrow(pos=vector(0,-40,0), axis=vector(0,40,0), shaftwidth=0.2,
color= color.black, length =80, headlength = 2, headwidth =1)
y_axis = arrow(pos=vector(0,0,40), axis=vector(0,0,-40), shaftwidth=0.2,
color= color.black, length =80, headlength = 3, headwidth =1)
T_x = text(text='X',
align='center', color=color.black, pos = vector(-52,0,0),
billboard =True, height =2)
T_y = text(text='Z',
align='center', color=color.black, pos = vector(0,-43,0),
billboard =True, height =2)
T_z = text(text='Y',
align='center', color=color.black, pos = vector(0,0, 43),
billboard =True, height =2)
T_x.width = 2*T_x.width
T_y.width = 2*T_y.width
T_z.width = 2*T_z.width
我正在尝试使用 vpython 在两个向量之间创建一个角度符号。这些向量是源向量和该向量的 x-y 投影。我正在使用 vpython 包,特别是来自 vpython 的 shapes
模块的 arc
。
from vpython import *
import numpy as nump
scene2 = canvas(title='Source Vector',
width=800, height=600,
center=vector(0,0,0), background=color.white)
scene2.select()
geophone = pyramid(pos=vector(0,0,0), size=vector(2,2,2),
color = color.green, up = vector(-1,0,0))
shot_loc = sphere(pos=vector(-20,30,-20),
size=vector(2,2,2), color= color.red)
shot_loc_label = label(pos=shot_loc.pos,
text='Vib Shot', xoffset=-30,
yoffset=30, space=10,
height=12,
font='serif')
ray_vector = arrow(pos=vector(0,0,0), axis=shot_loc.pos,
shaftwidth=0.2, color= color.blue, length =40, headlength = 2, headwidth =1)
ray_vec_label = label(pos=(ray_vector.axis - ray_vector.pos)/2,
text='Ray Vector', xoffset=-30,
yoffset=30, space=10,
height=12,
font='sans')
source_vector = arrow(pos=vector(0,0,0), axis= vector(20,-30, 20),
shaftwidth=0.2, color= color.red, length =30, headlength = 2, headwidth =1)
projection_of_source_vector = cylinder(pos=vector(0,0,0), axis= vector(20,0, 20),
radius=0.2, color=color.green)
source_vec_label = label(pos=source_vector.axis,
text='Source Vector', xoffset=30,
yoffset=30, space=10,
height=12,
font='sans')
plunge_angle = diff_angle(vector(20,0, 20),vector(20,-30, 20))
plung_arc = shapes.circle(radius=10, angle1=0, angle2=plunge_angle, np=10, rotate=90)
extrusion(path=[vector(20,0, 20), vector(20,-30, 20)],
shape=plung_arc)
x_axis = arrow(pos=vector(-50,0,0), axis=vector(50,0,0), shaftwidth=0.2,
color= color.black, length =100, headlength = 2, headwidth =1)
z_axis = arrow(pos=vector(0,-40,0), axis=vector(0,40,0), shaftwidth=0.2,
color= color.black, length =80, headlength = 2, headwidth =1)
y_axis = arrow(pos=vector(0,0,40), axis=vector(0,0,-40), shaftwidth=0.2,
color= color.black, length =80, headlength = 3, headwidth =2)
T_x = text(text='X',
align='center', color=color.black, pos = vector(-52,0,0),
billboard =True, height =2)
T_y = text(text='Z',
align='center', color=color.black, pos = vector(0,-43,0),
billboard =True, height =2)
T_z = text(text='Y',
align='center', color=color.black, pos = vector(0,0, 43),
billboard =True, height =2)
T_x.width = 2*T_x.width
T_y.width = 2*T_y.width
T_z.width = 2*T_z.width
3d cartisian
终于自己搞定了。在 jupyter notebook 中编写的这段代码的结果如附图所示。我正在使用 vpython 新版本,它可以在 jupyter notebook 中 运行。
无法完成的一个是使用 Latex 编写 theta 和 alpha。
from vpython import *
import numpy as nump
scene2 = canvas(width=800, height=600,
center=vector(0,0,0), background=color.white)
scene2.select()
geophone = pyramid(pos=vector(0,0,0), size=vector(2,2,2),
color = color.green, up = vector(-1,0,0))
geophone_label = label(pos=geophone.pos,
text='Geophone', xoffset=-30,
yoffset=-20, space=10,
height=12,
font='sans')
shot_loc = sphere(pos=vector(-20,30,-20),
size=vector(2,2,2), color= color.red)
shot_loc_label = label(pos=shot_loc.pos,
text='Vib Shot', xoffset=-30,
yoffset=30, space=10,
height=12,
font='sans')
ray_vector = arrow(pos=vector(0,0,0), axis=shot_loc.pos,
shaftwidth=0.2, color= color.blue, length =40, headlength = 2,
headwidth =1)
ray_vec_label = label(pos=(ray_vector.axis - ray_vector.pos)/2,
text='Ray Vector', xoffset=-30,
yoffset=30, space=10,
height=12,
font='sans')
source_vector = arrow(pos=vector(0,0,0), axis= vector(20,-30, 20),
shaftwidth=0.2, color= color.red, length =30, headlength = 2,
headwidth =1)
projection_of_source_vector = cylinder(pos=vector(0,0,0), axis= vector(20,0, 20),
radius=0.2, color=color.green)
source_vec_label = label(pos=source_vector.axis,
text='Source Vector', xoffset=30,
yoffset=30, space=10,
height=12,
font='sans')
plunge_angle = diff_angle(vector(20,0, 20),vector(20,-30, 20))
plung_arc = shapes.arc(radius=10, angle1=0, angle2=-plunge_angle)
b = cross(vector(20,0, 20),vector(20,-30, 20))
norm_vector = norm(b)
extrusion(path=[vector(0,0, 0), norm_vector],
shape=plung_arc)
plunge_label = label(pos=vector(4,-4,4),
text='α', xoffset=30,
yoffset=-20, space=10,
height=12,
font='sans')
back_azimuth_angle = diff_angle(vector(20,0, 20),vector(0,0, -1))
back_azimuth_arc = shapes.arc(radius=10, angle1=0, angle2=back_azimuth_angle)
c = cross(vector(20,0, 20),vector(0,0, -1))
norm_vector_azimth = norm(c)
extrusion(path=[vector(0,0, 0), norm_vector_azimth],
shape=back_azimuth_arc)
azimuth_label = label(pos=vector(3,0,-2),
text='θ', xoffset=30,
yoffset=30, space=10,
height=12,
font='sans')
x_axis = arrow(pos=vector(-50,0,0), axis=vector(50,0,0), shaftwidth=0.2,
color= color.black, length =100, headlength = 2, headwidth =1)
z_axis = arrow(pos=vector(0,-40,0), axis=vector(0,40,0), shaftwidth=0.2,
color= color.black, length =80, headlength = 2, headwidth =1)
y_axis = arrow(pos=vector(0,0,40), axis=vector(0,0,-40), shaftwidth=0.2,
color= color.black, length =80, headlength = 3, headwidth =1)
T_x = text(text='X',
align='center', color=color.black, pos = vector(-52,0,0),
billboard =True, height =2)
T_y = text(text='Z',
align='center', color=color.black, pos = vector(0,-43,0),
billboard =True, height =2)
T_z = text(text='Y',
align='center', color=color.black, pos = vector(0,0, 43),
billboard =True, height =2)
T_x.width = 2*T_x.width
T_y.width = 2*T_y.width
T_z.width = 2*T_z.width