Coding Challenge

แชร์
ฝัง
  • เผยแพร่เมื่อ 2 มิ.ย. 2024
  • Can I draw and rotate a 3D cube using Processing's 2D renderer with just some math?!?! Yes! Watch to learn more about rotation and projection matrices along with perspective and orthographic projection! Code: thecodingtrain.com/challenges...
    🕹️ p5.js Web Editor Sketch: editor.p5js.org/codingtrain/s...
    🎥 Previous video: • Coding Challenge #111:...
    🎥 Next video: • Coding Challenge #113:...
    🎥 All videos: • Coding Challenges
    References:
    💾 Matrix Multiplication: matrixmultiplication.xyz
    🗄 Rotation Matrix on Wikipedia: en.wikipedia.org/wiki/Rotatio...
    🗄 3D Projection on Wikipedia: en.wikipedia.org/wiki/3D_proj...
    Videos:
    🚂 Matrix Math: • 10.6: Neural Networks:...
    🚂 Matrix Multiplication for 3D Rendering: • Matrix Multiplication ...
    🔴 Coding Train Live 148.1: • Coding Train Live #148...
    Related Coding Challenges:
    🚂 #26 3D Supershapes: • Coding Challenge #26: ...
    🚂 #113 4D Hypercube (aka 'Tesseract'): • Coding Challenge #113:...
    🚂 #142 Rubik's Cube: • Coding Challenge #142:...
    Timestamps:
    0:00 Introducing today's topic: 3D rendering in 2D
    2:08 Let's begin coding!
    7:50 Add a projection matrix
    12:00 Add a rotation matrix
    18:02 Make a cube with 8 points
    20:41 Normalize the cube
    21:45 Connect the edges
    28:09 Add perspective projection
    31:36 Conclusion and next steps
    Editing by Mathieu Blanchette
    Animations by Jason Heglund
    Music from Epidemic Sound
    🚂 Website: thecodingtrain.com/
    👾 Share Your Creation! thecodingtrain.com/guides/pas...
    🚩 Suggest Topics: github.com/CodingTrain/Sugges...
    💡 GitHub: github.com/CodingTrain
    💬 Discord: thecodingtrain.com/discord
    💖 Membership: th-cam.com/users/thecodingtrainjoin
    🛒 Store: standard.tv/codingtrain
    🖋️ Twitter: / thecodingtrain
    📸 Instagram: / the.coding.train
    🎥 Coding Challenges: • Coding Challenges
    🎥 Intro to Programming: • Start learning here!
    🔗 p5.js: p5js.org
    🔗 p5.js Web Editor: editor.p5js.org/
    🔗 Processing: processing.org
    📄 Code of Conduct: github.com/CodingTrain/Code-o...
    This description was auto-generated. If you see a problem, please open an issue: github.com/CodingTrain/thecod...
    #3drendering #projectionmatrix #perspectiveprojection #rotationmatrix #processing

ความคิดเห็น • 260

  • @cicciobombo7496
    @cicciobombo7496 5 ปีที่แล้ว +135

    19:00 technically the light source is infinitely far away
    19:43 applying the X matrix to the PVector, then applying the Y and Z matrixes is the same as applying a single XYZ matrix. This XYZ is made matmultipling Z with Y and then the result with X. The order matters.
    Graphically Z×(Y×(X×V)) == (Z×Y×X)×V

    • @TheCodingTrain
      @TheCodingTrain  5 ปีที่แล้ว +42

      Thank you for these corrections! That's especially important pointing out the "infinite distance" of the light source. I will pin this comment!

    • @ericvega9160
      @ericvega9160 4 ปีที่แล้ว

      @@TheCodingTrain th-cam.com/video/6_sUVhH7VfU/w-d-xo.html

    • @ericvega9160
      @ericvega9160 4 ปีที่แล้ว

      @@TheCodingTrain sorry again, can you give me any advice how to draw all faces the math or something, thanks

    • @kun4i_135
      @kun4i_135 2 ปีที่แล้ว

      I understood everything absolutely.

    • @sethmobit
      @sethmobit 2 ปีที่แล้ว +1

      If we put to spin 90°, it doesn't spin exactly a quarter of the cube. And if we put to add +1 to angle at each second, from 0 to 90, it spins 360° some times instead only a quarter for one time. Why we couldn't simply put to rotate the exactly angle that we want?

  • @ThankYouESM
    @ThankYouESM 3 ปีที่แล้ว +68

    I really felt the need to learn how to create 3D from scratch for the sake of my own sanity, so thank you again.

  • @hemaangs3024
    @hemaangs3024 5 ปีที่แล้ว +43

    The way this guy speaks and gestures had me on the edge of my seat throughout the video

  • @wheellan
    @wheellan 3 ปีที่แล้ว +49

    I've been a professional developer for like, 3 years now, but this dude is still too much fun and I wish I had found him in college.

    • @kluplau
      @kluplau 3 ปีที่แล้ว +5

      I've been a professional developer for 15 years and still very much enjoy watching him. ☺️

  • @cmanshopdopler9354
    @cmanshopdopler9354 5 ปีที่แล้ว +96

    Not the hero we deserve, but the hero we need

  • @beastbomber2316
    @beastbomber2316 2 ปีที่แล้ว +22

    Here is a python version for everyone :P
    Make sure you have gasp and numpy
    from gasp import *
    import numpy as np
    #Settings
    back = color.BLACK
    dot = color.WHITE
    linec = color.GRAY
    scale = 200
    timestep = 0.05
    distance = 2
    #Dont mess with the ones below
    centerx = 0
    centery = 0
    angle = 0
    points = np.array([
    [-0.5, -0.5, -0.5],
    [0.5, -0.5, -0.5],
    [0.5, 0.5, -0.5],
    [-0.5, 0.5, -0.5],
    [-0.5, -0.5, 0.5],
    [0.5, -0.5, 0.5],
    [0.5, 0.5, 0.5],
    [-0.5, 0.5, 0.5]
    ])
    def draw():
    rotationZ = np.array([ #These have to be inside the function because angle will still static when initiailzing.
    [np.cos(angle), -np.sin(angle), 0],
    [np.sin(angle), np.cos(angle), 0],
    [0, 0, 1]
    ])
    rotationX = np.array([
    [1, 0, 0],
    [0, np.cos(angle), -np.sin(angle)],
    [0, np.sin(angle), np.cos(angle)],
    ])
    rotationY = np.array([
    [np.cos(angle), 0, -np.sin(angle)],
    [0, 1, 0],
    [np.sin(angle), 0, np.cos(angle)]
    ])
    projected = []
    for v in points:
    rotatedY = np.matmul(rotationY, v)
    rotatedX = np.matmul(rotationX, rotatedY)
    rotatedZ = np.matmul(rotationZ, rotatedX)
    z = 1 / (distance - rotatedZ[2])
    projection = np.array([
    [z, 0, 0],
    [0, z, 0]
    ])
    projected2d = np.matmul(projection, rotatedZ)
    projected2d = projected2d * scale
    point(projected2d[0], projected2d[1])
    projected.append(projected2d)
    for i in range(4):
    connect(i, (i + 1) % 4, projected)
    connect(i + 4, ((i + 1) % 4) + 4, projected)
    connect(i, i + 4, projected)
    def createWindow():
    begin_graphics(width=800, height=600, title="3D Renderer", background=back)
    return 400, 300
    def point(x, y):
    Circle((x + centerx, y + centery), 2, True, dot, 5)
    def connect(i, j, points):
    a = points[i]
    b = points[j]
    Line((a[0] + centerx, a[1] + centery), (b[0] + centerx, b[1] + centery), linec)
    def clear():
    clear_screen()
    centerX, centerY = createWindow()
    centerx = centerX
    centery = centerY
    while True:
    draw()
    time.sleep(timestep)
    clear()
    angle = angle + 0.1

  • @ArthurCousseau
    @ArthurCousseau 5 ปีที่แล้ว +5

    I've been working in 3d game development for nearly 2 years now, and still I learn a lot from your videos! Your work here is a real goldmine, and really accessible to future generations of coders. That's awesome.

  • @gathorn
    @gathorn 5 ปีที่แล้ว +7

    the explanation and the analogy with the shadow were just amazing

  • @hexcodeff6624
    @hexcodeff6624 4 ปีที่แล้ว +59

    18:44
    "This works to fast"
    -no programmer ever

  • @franeklubi
    @franeklubi 5 ปีที่แล้ว +2

    Yes! Thank you Dan, you're making me so happy with these videos! :D

  • @lidestudios5094
    @lidestudios5094 2 ปีที่แล้ว

    Exactly the type of information I've been searching for -- thanks for taking the time to make this and explain everything! I'll create something epic in the future with this power

  • @morto360
    @morto360 5 ปีที่แล้ว +3

    AMAZING!!!! If somebody asked me to do this, I wouldnt even dare to try since I thought is super complex... had no idea it can be so easy!!

  • @azyfloof
    @azyfloof 5 ปีที่แล้ว +36

    "I'm going to reward myself with a piece of space melon"
    This is the future :P

  • @lefantastique59
    @lefantastique59 2 ปีที่แล้ว +4

    This video inspired me to code my own 3D modelisation software for my final school project. So thank you so much!

  • @Jianju69
    @Jianju69 5 ปีที่แล้ว +3

    You're so good-natured that you make coding fun.

  • @kevnar
    @kevnar 5 ปีที่แล้ว +8

    Coding Challenge for you, Daniel: Create a 2D maze (as in your maze challenge), then render it in first person perspective using points and lines as in this challenge. Let the user walk around in it with keyboard clicks and mouse looking.
    I attempted this years ago in Visual Basic 6.0, without knowing any of this matrix math. It nearly broke my brain.

    • @loafy8532
      @loafy8532 5 ปีที่แล้ว

      that would be fun, but probably would take a very long time to do

  • @camerobaird5939
    @camerobaird5939 5 หลายเดือนก่อน

    Why did that make sense in the most confusing way possible? Thank you for this

  • @woobie5649
    @woobie5649 3 ปีที่แล้ว +1

    This a best explanation i've seen in youtube about this theme. Thank you so much

  • @Naej7
    @Naej7 5 ปีที่แล้ว +12

    OMG when you applied the perspective the first time, I couldn’t see the cube in the right way ! I was just seeing a kind of jelly wobbling xD

  • @oeq57
    @oeq57 4 ปีที่แล้ว +1

    Was doing this at work today, came back to your video for reference. Thanks Dan :D

  • @gloubiboulgazeblob
    @gloubiboulgazeblob 4 ปีที่แล้ว

    First nice and easy explanation of 3D rendering I see in my life. Thanks !!!

  • @benny.6588
    @benny.6588 2 ปีที่แล้ว +1

    you are really a genious...i was maing something like this for fun in 2000 year, but i did not reach so far, and with this deep understaning, you are my inspirational mentor , thanks dude

  • @beaverjoe9171
    @beaverjoe9171 5 ปีที่แล้ว

    I saw the content on the slack several days ago and I can saw it on TH-cam now! AMAZING

  • @rebornreaper194
    @rebornreaper194 ปีที่แล้ว

    I like your channel. You have such a great attitude, and you're clearly knowledgeable -- but you also show that it's ok not to know everything. You foster a great attitude towards ongoing learning. 😄👏

  • @Jaultaub
    @Jaultaub 5 ปีที่แล้ว +53

    I always wondered how 3D rendering works. Never thought that it was that 'easy'.
    I now really want to build this in C and draw 3D stuff to the console!

    • @Dzatoah
      @Dzatoah 5 ปีที่แล้ว +2

      You cant draw in a Console i think

    • @xxslajerxx8890
      @xxslajerxx8890 5 ปีที่แล้ว +10

      Well... he can draw box using - and | so he kinda can create 3d stuff in console.

    • @Jaultaub
      @Jaultaub 5 ปีที่แล้ว +2

      @@xxslajerxx8890 that is what i will be doing.

    • @Jaultaub
      @Jaultaub 5 ปีที่แล้ว

      I don't know if it worked but I at least tried to share my code:
      I have added the code and video to the contributions! Feel free to check it out!
      Edit: Please don't mind the commented out garbage in the main function, I forgot that it was there and now I don't know how to change the file.

    • @Jaultaub
      @Jaultaub 5 ปีที่แล้ว +3

      Therefore I will just add a link to the code: down
      +
      +
      +
      edit: gist.github.com/spulilol/4732968c3073faf8a42d2b7477caf929

  • @MattBee2k2
    @MattBee2k2 5 ปีที่แล้ว

    Love the videos and your energy man!

  • @kartoffellicht863
    @kartoffellicht863 ปีที่แล้ว

    Love it! love everything! Love coding! Love examples! Love humor! EVERYTHING!!

  • @nvadot1633
    @nvadot1633 5 ปีที่แล้ว +25

    Shoot, now I'm hyped to try implement this myself... Well, here goes my night

  • @mikee.
    @mikee. 5 ปีที่แล้ว +5

    Wow processing is amazingly simple!

    • @PandoraMakesGames
      @PandoraMakesGames 5 ปีที่แล้ว +3

      Yeah, I've made some cool things with it. IDE could be a little better, but the framework is great.

  • @Pilosofia
    @Pilosofia 2 ปีที่แล้ว

    in my university they told us to build 3d objects from scratch. you do a crazy things with this library. I can't imagine myself build something similar but I will try

  • @chaos6094
    @chaos6094 5 ปีที่แล้ว +1

    Amazing video, thank you!

  • @DogwafflDan
    @DogwafflDan 5 ปีที่แล้ว

    Enjoyed this one quite a lot!

  • @giorgosd3624
    @giorgosd3624 5 ปีที่แล้ว +5

    Nice video, looking forward into higher dimensions!
    Also a guest video would be nice, been a long time since the last

  • @gillesvismara5228
    @gillesvismara5228 5 ปีที่แล้ว

    Thank you, thank you for everything!

  • @ayostatue8448
    @ayostatue8448 3 ปีที่แล้ว

    thanks to your tutorial i created something that does essentially the same thing in pico8. this is a-ma-zing, keep it up

  • @jeeaile5835
    @jeeaile5835 5 ปีที่แล้ว +4

    I don’t watch the entire video but i’ve already liked

  • @tonysfun
    @tonysfun 5 ปีที่แล้ว

    Very talented young man!!! Love your video!

  • @flwi
    @flwi ปีที่แล้ว

    Awesome video! Just what I needed for my advent of code problem

  • @cazino4
    @cazino4 4 ปีที่แล้ว

    Great videeo as ever. Well done!!

  • @emteiks
    @emteiks 2 ปีที่แล้ว

    A Giant at work. Thanks for making this video!

  • @kantyDarius
    @kantyDarius 5 ปีที่แล้ว +1

    awesome, i´d made a program in visual basic a couple years ago that use topographic images of mars´s surface transforming the colors and position of each pixel into an array of values then pass this values to the program por render in 3d with zoom in, zoom out, rotation, water flood simulation and a couple of features more (sorry por my english)

  • @seth-blank
    @seth-blank 9 หลายเดือนก่อน

    Finally someone actually explained projection matrix's :D

  • @rodneykingston6420
    @rodneykingston6420 4 ปีที่แล้ว

    Any book or tutorial on WebGL or OpenGL should start with exactly the material covered in this video and the previous one, before any GL code is even introduced. Showing how matrix multiplication of vertexes work and how specific matrices can be utilized with point and line drawing primitives of a 2D library to achieve 3D effects - WOW! Brilliant. Just Brilliant. Thanks for clearing up a previously foggy area for me.

  • @allurbase
    @allurbase 5 ปีที่แล้ว +3

    Good that you fixed that extra zero, was making me crazy that it was working even though that typo

  • @phos4us
    @phos4us 4 ปีที่แล้ว +1

    my algorithm for drawing lines is just an array of 12 smallers arrays of 2 that store the two indices needed for each line and it cycles through it.

  • @iosgamer158
    @iosgamer158 5 ปีที่แล้ว

    Really interesting video thank you and keep up the good work 😃

  • @ricardo.mazeto
    @ricardo.mazeto 5 ปีที่แล้ว +3

    Daniel, you're so close to make a full 3D graphics engine!

  • @roshanpawara8717
    @roshanpawara8717 5 ปีที่แล้ว +2

    I have the same shirt. Same pinch!

  • @alfonsoknows3318
    @alfonsoknows3318 5 ปีที่แล้ว +1

    i just did this coding challenge myself in processing. But as i just learned quaternions, i did all the rotating thingies with quaternions instead of matrices. It was veeery satisfying, seeing the cube rotate in the end around really any 3d axis.....

    • @TheCodingTrain
      @TheCodingTrain  5 ปีที่แล้ว +2

      Did you watch the 3Blue1Brown video? I am excited to try some Quaternion examples!

    • @alfonsoknows3318
      @alfonsoknows3318 5 ปีที่แล้ว +1

      @@TheCodingTrain Yes i did. That's where i got the idea from actually... After watching the 3b1b video i read a few university lecture notes about quaternions and 3d rotations and when i then saw your video right here, i thought i could combine the two...

  • @sarveshwarans8037
    @sarveshwarans8037 5 ปีที่แล้ว

    I love to learn a lot from you..

  • @hamzaf19
    @hamzaf19 3 ปีที่แล้ว

    I love your videos and thanks you helped me a lot with that video tho!

  • @MrEven9401
    @MrEven9401 5 ปีที่แล้ว

    Very interesting video, math is just amazing.

  • @4greenkoalas
    @4greenkoalas 5 ปีที่แล้ว +6

    16:20 i was screaming at my screen for the missing comma and extra 0

  • @sana181019811
    @sana181019811 5 ปีที่แล้ว

    I love this😍😍💻

  • @cashel1111
    @cashel1111 5 ปีที่แล้ว +1

    i know you just uploaded this, but would love to download the code :)
    that perspective explanation is the first that has made sense to me, keep it up

    • @TheCodingTrain
      @TheCodingTrain  5 ปีที่แล้ว

      You can find it at thecodingtrain.com! (Oh, actually the page is broken for some reason, looking into it.) Code is here: github.com/CodingTrain/website/tree/master/CodingChallenges/CC_112_3D_Rendering

  • @kirbofn524
    @kirbofn524 10 หลายเดือนก่อน

    Anyone following 4 years later… at the point where you connect the lines, simply in the for v : points loop, save the last screen coordinate in a non loop local variable (as in declared outside) then check, if it has been initiated (had a value) then draw a line between it and the current point

  • @gibbermagash5559
    @gibbermagash5559 5 ปีที่แล้ว +2

    So I ran into two erros I can't fix. "The function "matmul()" expects parameters like "matmul(float[ ][ ], PVector)" and "Duplicate local variable v". I couldn't find an error in my code so I copied the codes from the links into the P3 editor and got the same errors.

  • @Looki2000
    @Looki2000 2 ปีที่แล้ว +1

    you can caclculate the focal length for perspective projection with "focal_length = window_height/2 * cot(fov) / 2)". Dont forget to remove that scaling at 21:09

  • @bennguyen1313
    @bennguyen1313 3 ปีที่แล้ว

    Do you have any suggestions on how to plot live-data, that comes from the usb/serial-port? P5JS , PixiJS , ZIMJS, TwoJS?
    For example, not sure which package would best keep up drawing a simple line graph, as the data that comes streaming in, but I'd *LOVE* to use P2D, maybe with Python!

  • @BaronVonTacocat
    @BaronVonTacocat 5 ปีที่แล้ว

    Cool video, homie!

  • @juicepops7819
    @juicepops7819 4 ปีที่แล้ว +9

    13:26 everytime I get an error in my code

  • @sukhWins
    @sukhWins 4 ปีที่แล้ว

    My favorite channel

  • @SaifullahUsmani
    @SaifullahUsmani 2 ปีที่แล้ว

    You are amazing 🤩

  • @matejnovosad9152
    @matejnovosad9152 5 ปีที่แล้ว +1

    Awesome

  • @freerunner1508
    @freerunner1508 5 ปีที่แล้ว

    You insane coder

  • @peterlous853
    @peterlous853 5 ปีที่แล้ว +1

    Nice coding challange! How do you prevent division by zero when doing the perspective projection (i.e. distance - rotated.z = 0)?

  • @mindaugasdudenas624
    @mindaugasdudenas624 5 ปีที่แล้ว

    Thank you for this, but I try for a couple of hours to understand how I could do the same with the planes ( begin shape end shape ). So I would have a fill over it, but it just does not work in my head so far. Any guidance would be much appreciated.

  • @irmansyah842
    @irmansyah842 5 ปีที่แล้ว

    its amazing

  • @yotubeaccoutsuperawesome
    @yotubeaccoutsuperawesome 4 ปีที่แล้ว

    Where can I learn more about this? I'm hoping to learn as much as possible. I really need to improve my canvas game.

  • @puppergump4117
    @puppergump4117 2 ปีที่แล้ว

    I got everything right (using cpp) but I have a couple problems.
    Firstly, the z values separate the two layers of cube opposite each other. Basically I now have two squares rotating around an empty space.
    It also keeps rotating around the upper left corner (the origin). I tried subtracting the point's position with the cube's position and it kind of centered, but it always rotates around with the upper left point pointing toward the rotation point. I cannot get the rotation point to be inside the cube. When I tried, everything froze.
    The worst part is that I just did exactly what you did. I can only guess that there are more 3d helping tools in processing, even without the 3d functions.

  • @Johnedyy
    @Johnedyy 5 ปีที่แล้ว

    You are my Idol ♥

  • @Guysudai1
    @Guysudai1 5 ปีที่แล้ว +11

    I did the same thing in assembly as a school project(only for more shapes)

    • @nvadot1633
      @nvadot1633 5 ปีที่แล้ว +2

      Guysudai1 in assembly?? O_o mind sharing the source code, you got me curious...

    • @Guysudai1
      @Guysudai1 5 ปีที่แล้ว +2

      uploaded it to github.com/guysudai1/asm-project

    • @nvadot1633
      @nvadot1633 5 ปีที่แล้ว +2

      Guysudai1 holy.cow, that's impressive!! Thanks for sharing!!

    • @Guysudai1
      @Guysudai1 5 ปีที่แล้ว

      @@nvadot1633 no problem!

    • @otesunki
      @otesunki 5 ปีที่แล้ว +2

      Woah, In ASSEMBLY!?!??!?! if you can do that, you can do anything!

  • @gillesvismara5228
    @gillesvismara5228 5 ปีที่แล้ว

    thank you!!!!

  • @vladthe_cat
    @vladthe_cat 10 หลายเดือนก่อน

    6:34 omg that looks familiar!
    Thank you Linear Algebra & Matrix Theory!

  • @Tomyk9991
    @Tomyk9991 5 ปีที่แล้ว

    will machine learning and ml5 be available in processing itself sometime?

  • @ejskshrvhshsbdbdbddhdh3yej11
    @ejskshrvhshsbdbdbddhdh3yej11 2 ปีที่แล้ว

    You r the best teacher

  • @stalkerkk
    @stalkerkk 3 ปีที่แล้ว

    Literally no body able to explain that simple projection matrix that simple, I was to give up 3d programming and my TH-cam shows your video.

  • @kevnar
    @kevnar 4 ปีที่แล้ว

    In a past life, Daniel was a mad scientist.

  • @truefiasco2637
    @truefiasco2637 5 ปีที่แล้ว

    I would really like to see how you'd render 4d rotations as they look really cool, I've tried doing it in Processing without any success, I've been able to "rotate" a hyper cube in "4d "

  • @_rgrtht
    @_rgrtht 5 ปีที่แล้ว +2

    i love your channel

    • @PandoraMakesGames
      @PandoraMakesGames 5 ปีที่แล้ว +1

      Same, inspiration for my own AI videos :)

  • @androidworld3239
    @androidworld3239 3 ปีที่แล้ว

    could i know where do you get (draw and render functions)?
    thank you

  • @Illusionaire1
    @Illusionaire1 5 ปีที่แล้ว

    I've watched both this and the livestream, and I'm always lost on why the matrices have 3 rows. A point X, Y and Z shouldn't be only row on the Matrix? 3 cols, 1 row? How does that become 3 cols, 3 rows?

  • @anandaperumalb1044
    @anandaperumalb1044 5 ปีที่แล้ว

    thats cool sir

  • @Mustafaq9
    @Mustafaq9 5 ปีที่แล้ว

    Hey Dan, you want to make sure your rotation matrix for the Y axis is correct. The signs on the sin(angle) get swapped for Y, I don't think you've done that.

    • @TheCodingTrain
      @TheCodingTrain  5 ปีที่แล้ว

      Can you point me to a timecode where I got it wrong? Or file an issue related to the code here? github.com/CodingTrain/website/issues

    • @Mustafaq9
      @Mustafaq9 5 ปีที่แล้ว

      @15:34 is where you created the Y rotation matrix. It should be
      [cos 0 sin
      0 1 0
      -sin 0 cos]

  • @franciscotorre7702
    @franciscotorre7702 3 ปีที่แล้ว

    U RE GREAT

  • @int16_t
    @int16_t 3 ปีที่แล้ว

    I hope you defined the direction of x y z.
    It's quite confusing whether z is the vertical axis or y.

  • @sarveshwarans8037
    @sarveshwarans8037 5 ปีที่แล้ว

    Love your vedio

  • @neontiger2007
    @neontiger2007 4 ปีที่แล้ว

    Lol, dude. You are crazy but you are brilliant, and so was your video. First video I've seen from you. Plain subscribe, of course.
    I hope I can understand these topics because I would LOVE to be able to make a 2D perspective based tennis game (like Mario Tennis for Gameboy Advance) but with the aesthetics and fun of a Kunio-kun no-Nekketsu game.
    Hugs from Argentina.
    P.S: Excuse my awkward English by the way.

  • @silvertakana3932
    @silvertakana3932 3 ปีที่แล้ว

    Shiffman “Oh boy! this work too fast. I didn’t want it to work that fast”.
    All other programmers drop their mouth

  • @eagle32349
    @eagle32349 หลายเดือนก่อน

    26:29 Here is the algorithm:
    int k = 0;
    for (int i = 1; i < 5; ++i) { int l = 1;
    for (int j = 1; j < 5; ++j) drawLine(hdc, p[k], p[l += j]);
    k += i;
    }

  • @kimung203
    @kimung203 5 ปีที่แล้ว +3

    The coding train: I finished a 3d cube
    Tesseract: hold my beer
    The coding train: hahahaha **breathes** no you
    Penteract: hold my vodka
    The coding train: oh hell no

  • @vahe.gevorgyan
    @vahe.gevorgyan ปีที่แล้ว

    Where can i find functions that he has written before and using now?

  • @GeneralPet
    @GeneralPet 4 ปีที่แล้ว

    I know this is done in processing, but there's got to be some some way to use hardware acceleration for matrix operations.

  • @JiwooLee
    @JiwooLee 4 ปีที่แล้ว

    Hi I get an error trying to run P3D on my mac and google says it might be an OS problem. How did you get it to work on your computer?

  • @inferious777
    @inferious777 4 ปีที่แล้ว

    Im writing this in javascript canvas from scratch. My current rotation axis is the axes themselves (x,y,z), trying to find a way to move it to the midpoint of the object.

    • @inferious777
      @inferious777 4 ปีที่แล้ว

      nvm, solved it by translating all points back to the center and translate it back after.

  • @bakisha
    @bakisha 5 ปีที่แล้ว

    And here i am, trying to search a way to program arduino 8x8x8 RGB led cube to do rotating cube animation. Interesting video, i found some useful info, plus that part in 24:50...

  • @ScaredHelmet
    @ScaredHelmet ปีที่แล้ว

    How can you change it so when you move the cube up, down, left or right, it still spins around its own center instead of the center of the screen?

  • @swatantramukherjee7202
    @swatantramukherjee7202 5 ปีที่แล้ว

    I want to make a program that will accept length, width and height from user at run time. Based on the user input a 3d box will be created. Can I achieve this using Java Applet or Swing? if not then what programming language and tools I need to use?

  • @ArchiesWorkshop
    @ArchiesWorkshop 5 ปีที่แล้ว

    So if I would like to fill the quads with some color, how can I be sure that front polygons would be drawn after rear ones so they are not overlapping?

    • @TheCodingTrain
      @TheCodingTrain  5 ปีที่แล้ว

      Oh, this is a good extra challenge! You would have to "z sort" the shapes to draw from back to front.

    • @ArchiesWorkshop
      @ArchiesWorkshop 5 ปีที่แล้ว

      and what if I want them to be intersecting?)))

  • @alexfagan6249
    @alexfagan6249 3 ปีที่แล้ว +4

    ive been following along using python, so far everything works, until i add perspective. Anyone know the original perspective formula i should use?