Python 3D Graphics Tutorial 7: Vpython Model of a Thermometer

preview_player
Показать описание
You guys can help me out over at Patreon, and that will help me keep my gear updated, and help me keep this quality content coming:

In this video we show step-by-step instructions on how animate 3D designs and models in vpython, (visual python), and how to bring your models to life. In this example I will show how to create a 3D model of a thermometer. In future lessons we can bring the model to life with data coming from an Arduino and temperature sensor. I do not assume you are an expert, so these lessons are designed for complete beginners.
#Python
#Lessons
#Graphics
Рекомендации по теме
Комментарии
Автор

Sir, you are the most amazing human being on this planet. You are awesome. I've been following your videos for more than 2 years now..Keep up the good work. May god bless you!!!

bhanukadayawansa
Автор

Last week's homewok:
This week's homework is pretty easy!

aman-sood
Автор

I remember years (I mean years, last century) ago doing hobby 3 d animation on an Amiga computer, yes Amiga computer, lost but not forgotten and software called "Lightwave". A very cool package/system. With this series, its nice to sea the nuts and bolts of animation. Thanks Paul. Long live, in memory, the deceased Amiga!

tomaims
Автор

Paul, Many Many Congratulations, We Thank you so much for your
precious lessons, They help me a lot
watching you!

MrMarkatgrc
Автор

Did similar, but created a list to hold the tick names and placed the ticks on a box behind the thermometer. When I converted to parameters, I ended up creating the thermometer horizontally which looks good but was never able to rotate it properly to the angle I wanted... maybe I need to learn a bit more about rotation! :). Thanks for great teaching!

jalexromero
Автор

I struggled getting the second thermometer to run twice as fast without issue, the code isn't pretty but it got the job done. Really looking forward to your solution on this one. I AM LEGEND!

learningcode
Автор

Hi Paul, I haven't uploaded a video of my thermometer. I did get one to work but I got tangled up in stuff. I started with a backplate for the thermometer and the glass fitted nicely half way out of the back. However to get to that point I needed to work out how to rotate the cylinder to the vertical position which took me a long time to figure out. However I ended up Googling [ .rotate(angle=(1.5708)] to achieve this. I was a bit worn out by this time so I ended up watching this tutorial in which you explained everything including how to get the tick marks onto the "glass": cool! Anyway, I think I should be able to get the dual thermometers to work really well now. Thanks for another great tutorial.

alfredcalleja
Автор

I did mine differently. I did the mercury cylinder and cube, but put them against a white box (I put it so that half the sphere and cylinder were inside the box). I needed to watch the video for the markings though. Thank You Paul.

abdullahchoudhury
Автор

I am Legend!
At the time of this writing, visual studio seems to be having some trouble with Vpython. I have had to write my code differently than Mr.McWhorter to get my programs to run, and it seems that people online are having similar problems.
For these last few lessons and assignments, I have had trouble getting smooth animations. All my animations (including the code from the lessons), run at inconsistent speeds. Using print- statements, I found that the problem was associated with the "numpy" library. However, the code still struggled when I rewrote the program, changing "numpy" to range and adjusting parameters (it may have been a little better). I also ran the program on IDLE, which still struggled some, but was much better.
I think my code is correct. I just need to keep experimenting.

jonathanlanders
Автор

Just building my foundation and waiting to connecting ardiuno to visual python.😊😊😊
Amazing video again with amazing explaination.🙏🙏

atharvsinha
Автор

I folded... got into a rabbit hole trying to rotate the cylinder at the anchor point to have it face up... instead of rotating field of view with the mouse. Well, why go simple when we can go harder. Thanks Paul for another great h/w

maku
Автор

I am LEGEND and completed the homework, although I will admit I was sitting on a slightly wonky Walmart lawn chair for a while😊. My solution using threading, sort of worked, but wasn't great. Thank you @Keith Lohmeyer for reminding me about classes and methods. My solution using this worked a whole lot better.

kevingriffin
Автор

Thanks for this amaizing tutorial and good luck.

Nick-xzqq
Автор

Sir, after seeing Bible boy, I just blessed God for you. you're such an inspiration. am 30 and I just discovered if one wants to be like God, be an engineer. so I'm changing career. GOD BLESS YOU

africanpraise
Автор

Just joined this 3D playlist (in addition to your AI list). Got some catching up to do obviously. Thanks Paul.

Sikuq
Автор

Did the homework but having problems posting it to youtube, will keep trying. I used delta statements like in the bouncing ball program instead of FOR, IN RANGE or LINSPACE statements. Also had a lot of fun parameterize it.

petefontana
Автор

Hello, I may have a bad question but whatever, I really like your videos and it helps me out really well as Im doing final project at school that shows that u can 3D print models using Python, and my question to you is, if i can 3D print models that you do in videos with VPython? Thanks for answer.

marianprikryl
Автор

I folded like a cheap lawn chair. I rotated it using additional code and not just rotate it using the mouse haha. There are problems in my loop and just decided to see your solution.

shatterism
Автор

I am legend.
Made more work for myself than necessary here, I wanted a thermometer that changed colour from blue at the lowest point to green in the middle to red at the highest point. I also wanted the simulation to be the temperature of the thermometer varying from its highest to its point. There are considerably more lines of code in the simulation than in the declaration, and please forgive the slight fudge in line
from vpython import *
import numpy as np

# First declare the paramters...
Ht = 6 # Height of the thermometer tube
tuberad = 0.25 # Radius of the moving part of the thermometer
ballrad = 0.5 # Radius of the spherical part of the thermometer case (the base)
gap = 0.1 # Gap between the casing and the 'liquid'
liquidcol = [0, 0]

# Declare the semi-transparent casing, comprising of
# a sphere and a cylinder....

casingball = sphere(color = color.white, opacity = 0.3, radius = ballrad + gap, pos = vector(-Ht/2-(((ballrad + gap)**2 - (tuberad + gap)**2)**0.5), 0, 0))
casingtube = cylinder(color = color.white, opacity = 0.3, radius = tuberad + gap, length = Ht, pos = vector(-Ht/2, 0, 0))

# Declare the liquid parts....

liquidball = sphere(color = vector(liquidcol[0], 0, liquidcol[1]), radius = ballrad + 0.05, pos = vector(-Ht/2-(((ballrad + gap)**2 - (tuberad + gap)**2)**0.5), 0, 0))
liquidtube = cylinder(color = vector(liquidcol[0], 0, liquidcol[1]), radius = tuberad, length = Ht, pos = vector(-Ht/2, 0, 0))
# Without the + 0.05 in liquidball.radius there is a gap at the edges between the liquid tube and the liquid ball
# the 0.05 is a guess to get it looking a bit better as the maths are beyond my tired brain at present! :-)

while True:
for lent in np.linspace(0, Ht/2, 500):
rate(300)
liquidcol = [2*lent/Ht, 1 - 2*lent/Ht]
liquidball.color = vector(0, liquidcol[0], liquidcol[1]) # Increase green to 1,
liquidtube.color = vector(0, liquidcol[0], liquidcol[1]) # and decrease blue to 0.
liquidtube.length = lent
for lent in np.linspace(0, Ht/2, 500):
rate(300)
liquidcol = [2*lent/Ht, 1 - 2*lent/Ht]
liquidball.color = vector(liquidcol[0], liquidcol[1], 0) # Increase red to 1, and
liquidtube.color = vector(liquidcol[0], liquidcol[1], 0) # decrease green to 0.
liquidtube.length = lent + Ht/2
for lent in np.linspace(0, Ht/2, 500):
rate(300)
liquidcol = [2*lent/Ht, 1 - 2*lent/Ht]
liquidball.color = vector(liquidcol[1], liquidcol[0], 0) # Increase green to 1,
liquidtube.color = vector(liquidcol[1], liquidcol[0], 0) # and decrease red to 0.
liquidtube.length = Ht - lent
for lent in np.linspace(0, Ht/2, 500):
rate(300)
liquidcol = [2*lent/Ht, 1 - 2*lent/Ht]
liquidball.color = vector(0, liquidcol[1], liquidcol[0]) # Increase blue to 1,
liquidtube.color = vector(0, liquidcol[1], liquidcol[0]) # and decrease green to 0.
liquidtube.length = Ht/2 - lent

JackVersey
Автор

Hey Paul, I have loved your content over the years. Any reason why you haven’t done a series on how to do embedded software? It would be long but I don’t think it would truly be that hard for some people to grasp. Especially well document microcontrollers like the stm32 family. Arduino’s have there place but they are so limiting, and nobody on YouTube seems to want to make a series on how to code straight to a microcontroller

gianlucamazzi