חישוב נפח גופים תלת-ממדיים
נוסחה, קוד, ויזואליזציה: שלוש דרכים להבין את אותו מושג
נפח מנסרה מלבנית — שלושה ייצוגים של אותו רעיון
# Step 1: find the base area base_area = length * width # Step 2: multiply by height volume = base_area * height # Step 3: surface area sa = 2 * (l*w + l*h + w*h)
שימו לב: הצבעים עקביים — l בטורקיז בציור, בנוסחה ובקוד. w בציאן. h בכתום בכולם. נפח הוא תמיד סגול. המיפוי הזה הוא מנגנון הלמידה — לא כל ייצוג בנפרד, אלא החיבורים ביניהם.
מיפוי בין ייצוגים
כל שורה היא אותו דבר בשלוש צורות שונות:
| מתמטיקה | קוד Python | ויזואלי (SVG) | צבע |
|---|---|---|---|
| l (אורך) | length | צלע תחתונה קדמית | |
| w (רוחב) | width | צלע צידית לאחור | |
| h (גובה) | height | קו מקווקו כתום אנכי | |
| V (נפח) | volume | תווית בתוך התיבה | |
| SA (שטח פנים) | surface_area | סכום כל 6 הפאות |
מחשבון אינטראקטיבי — מנסרה מלבנית
שנו את הערכים וראו את כל שלושת הייצוגים מתעדכנים יחד:
גופים תלת-ממדיים נוספים
גליל — Cylinder
חרוט — Cone
כדור — Sphere
פירמידה מרובעת — Pyramid
קשר מפתיע: חרוט = ⅓ מגליל. פירמידה = ⅓ ממנסרה. כדור = ⅔ מהגליל שעוטף אותו. המכפיל ⅓ חוזר שוב ושוב כי כל גוף "מחודד" הוא בדיוק שליש מהגוף ה"ישר" התואם.
קוד Python מלא
הקוד המלא נמצא בקובץ volume_calculator.py — הוא כולל חישוב 7 צורות תלת-ממדיות, ויזואליזציה תלת-ממדית עם matplotlib, ותפריט אינטראקטיבי.
class VolumeCalculator: """Calculate volume and surface area of 3D solids.""" def rectangular_prism(self, length, width, height): # Step 1: compute volume volume = length * width * height # Step 2: compute surface area (all 6 faces) sa = 2 * (length*width + length*height + width*height) # Step 3: space diagonal diagonal = math.sqrt(length**2 + width**2 + height**2) return {'volume': volume, 'surface_area': sa, 'diagonal': diagonal} def cylinder(self, radius, height): volume = math.pi * radius**2 * height sa = 2 * math.pi * radius * (radius + height) return {'volume': volume, 'surface_area': sa} def cone(self, radius, height): slant = math.sqrt(radius**2 + height**2) volume = (1/3) * math.pi * radius**2 * height sa = math.pi * radius * (radius + slant) return {'volume': volume, 'surface_area': sa, 'slant_height': slant} def sphere(self, radius): volume = (4/3) * math.pi * radius**3 sa = 4 * math.pi * radius**2 return {'volume': volume, 'surface_area': sa} def square_pyramid(self, base_side, height): slant = math.sqrt(height**2 + (base_side/2)**2) volume = (1/3) * base_side**2 * height sa = base_side**2 + 2 * base_side * slant return {'volume': volume, 'surface_area': sa, 'slant_height': slant} # Run: python volume_calculator.py
זכרו: הקוד הוא תרגום של הנוסחה, לא מקור ההבנה. מישהו היה צריך לדעת ש-V = l×w×h כדי לכתוב אותו. הערך של הקוד: פירוק הנוסחה לשלבים ניתנים לעקיבה, אימות עם ערכים אמיתיים, ואיתור שגיאות.