A BETTER WAY to make a Tetrahedron in Blender Geometry Nodes

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi yes hello everyone I'm gavin. JS and today I wanted to address something that came up in the comments of the platonic solids video I got a question asking about this number that I used to create the tetrahedron and when I went back to figure out how I got that number I couldn't find any of my work unfortunately so while I said kind of cryptically in that video I did some math but I genuinely can't remember exactly what it was I did to calculate that I remember there being a lot of trial an error trying to figure out that value so instead of trying to reverse engineer what I did I figured why not give the tetrahedron another try and see if I can come up with a more logical tetrahedron that's more straightforward and doesn't have any confusing variables in it and if you like the work I do here in Geometry nodes I'd greatly appreciate it if you hit that subscribe button and gave the video a like it helps out the channel tremendously and I'd really appreciate it but without further Ado let's get into it so to get going here I've got a new scene and we are just going to quickly delete the default sphere and add in a cube now if we tab into edit mode what we're going to do is construct a tetrahedron so I'm just going to select the four corners that are all sort of opposites of each other I don't know I don't know exactly how to describe the locations of all of those but we're we just going to select those four corners of our Cube and hit delete and that leaves us with these four floating vertices and if we just select three at a time and hit F to fill slowly but surely we will reconstruct a tetrahedron which is pretty neat I think this is a pretty cool way to construct a tetrahedron by hand but unfortunately that's not the goal here I want to construct this in Geometry nodes so how would we go about doing the same thing but with geometry nodes so for once I'm actually going to open up the geometry nodes Tab and we've just got a blank scene so now what I want to do is sort of think through the same process that we just did by hand but doing it in Geometry nodes so now that we've got our Cube I'm just going to run through my first thought which was selecting each of the vertices that we want to get rid of and setting the points of that new geometry to the remaining points of our Cube and I in my head this made a lot of sense I know that this would be pretty short code if I were to just type it all out in python or whatever language but unfortunately with nodes it gets a little cumbersome and it's very involved or at least it feels unnecessarily involved it's not actually that complicated it's just there's so many nodes just to create the most basic platonic solid so in the end although I got what I wanted it's definitely not anything I would recommend anybody do now I did try a few different ways to get all of our vertices to delete the ones that we don't want and to keep the ones that we do but honestly all of it was super cumbersome I tried using modulus but like the rules for which indices we want and which ones we don't uh it's all just so incredibly tedious that I ended up scrapping all of this part but we'll we'll keep a large portion of this so I'm I'm really glad I went through all of these different trial and error sort of phases but overall we're just going to redo this and then I'll walk you through what all is happening in through here because one of the key takeaways here is that we've got all of the coordinates that we need well now hold on I forgot to merge all of my final points there we go up in our spreadsheet we've got the location of all of the vertices that we need which is really important because instead of trying to figure out from a cube which one's to keep and which one's not to keep what we can do is just set up four points from the beginning and manually set all of their coordinates now that sucks because even if I were to do this by hand I wish I had a node where I could just put in a CSV or something to make it take up less space and have fewer nodes but say that's way easier than trying to run through this or do any complicated modulus math so let's get that set up and then I'll walk you through all of the rest of what's going on here because I think it's pretty cool and there are a lot of really good takeaways from this workflow here okay so starting fresh let's get rid of our inputs and drop in a points node here we know we need all these fields to read at 0 five let's plug that in just so that we can see what's going on and make sure that things are looking good let's also just bring in a join geometry node so that we can visualize all of them as we're placing them in and then let's duplicate that and set both our X and Y to.5 then let's also duplicate those and plug them into our join geometry now let's set our x and z to.5 and our y and z to.5 and it doesn't really matter what the order is here any way you want to plug these in and join them all together will work so let's just squeeze that all together and I will resist the urge to clean it up and collapse everything but let's frame that up and label it initial points drag that off to the side and now what we want to do is build the actual mesh so we've established the location of each of our points but now we need all of the geometry so let's start that by adding in a mesh Circle set our number of vertices to three and we want to change our fill type from none to endon and it can be really tempting to set it to triangles but if we take a look at the wireframe if we set it to triangles that'll create this additional Point here in the middle which we do not want so set it to endon and this will work great now we need an instance on points node and we can plug our mesh circle into both points and instances switching back to shaded view we can see we've got three triangles that all connect right there on the points and we've got this middle that's empty so let's grab a transform geometry node give ourselves a little bit more space here and again plug our mesh circle into the transform geometry and so that we can see what we're doing let's join our geometry to together and in the transform node let's rotate on the z-axis by 60° now it is important that we bring the transform geometry node into our join geometry before our instances what that'll do is make sure that uh whichever one of these is labeled zero uh it'll be 0 1 2 here and then our instances will build off of that however they're labeled that doesn't matter right now and I'll explain that a little bit more here in a second because right now what we want to do is realize our instances and then merge by distance and now we've got all of the geometry that we need to build our tetrahedron and just real quick to explain what I was talking about if we drag in a delete geometry and a compare node set that to equal and bring in our index value what we'll see is that this point right here disapp appears because this is set to zero and as I increment through that we see that it goes 0 1 2 and then the outermost Corners 3 4 five that's very important because now what we're going to do is tell this hey if your index is less than three so 012 we want these inner points that are connected to the outer points to match to one of the triangles of our tetrahedron so we'll just simply match each index to the corresponding index on our tetrahedron and then we'll say if the value is over two then all of the rest of you go over to index three on our tetrahedron that's why it's so important that we have this triangle joined on top so that the middle triangle sets the indexes of everything else let's just frame everything up here and call that our new mesh move it over there so that we have a little bit more space now we're going to use our sample index node which recently I learned is an incredibly important node if you're not aware of that this is maybe one of the single most important nodes and I'm going to make an entire video just explaining why that is but for now what we're going to do is take our sample index node our position node and our index node so now we're going to change this from float to Vector plug in our position so that we're reading to position data from each of our initial points and then we can just plug in the index so that we read it for each index of those points and now we're going to duplicate this bring in that same set of geometry and also our position but what we're going to do is instead of sampling each index we just want to know the position of our third index so let's bring in a switch node change it from geometry to Vector plug our first sample index into false and our second into true then we need a compare node switch this from float to integer bring our index into the first input and then change our second input to two leave this at greater than and then we can plug that into our switch node then we just need our set position we can bring in our new mesh data and plug our switch node into position and when we plug that into our output we should see our tetrahedron let's switch back to our shaded view here and yeah there's our tetrahedron the very last thing we need to do besides some uh reorganization is to merge all of our vertices because as we see up here we've got six points and the reason that's happening is because we have six points created in our new mesh and we're taking three of them and putting them right here Al together so let's add that merge by distance node and we can see now we've got our four points all exactly where we want them nicely set up and that is our tetrahedron so now that I've got that all cleaned up and nicely labeled there's one more thing you're probably wondering about and that's the orientation of our tetrahedron normally we see it somewhat similar to a pyramid where we've got one point sticking up and honestly I like this orientation I think it's uh kind of nice it doesn't have that weird illusion where it looks like the center isn't actually in the center everything's nicely equidistance and all of our numbers are really nice but if you really want it to be standing upright what we can do is drop in just one more transform geometry node and rotate it on the x axis by 45° and it may be very tempting to just type in 45° here but that's uh not that's not what we want and I had to do a little bit of math and I know I said this in the initial tetrahedron clip but this math is actually fairly straightforward and I can run you through the logic real quick so if we take a look at the Y viewport here on set this back to zero we know that we need to rotate this whole shape by the angle between the midpoint of this line segment and this point the good news is we've got very nice numbers even though some of them have changed from our nice and simple 0.5 we've got negative 707 now so I just Chuck those into an online calculator to find the angle between this vector and this vector and I found that if we rotate by 35.262781 everything is good to go and with that thank you so much for watching and I will see you in the next one bye
Info
Channel: GavinDotJS
Views: 1,392
Rating: undefined out of 5
Keywords:
Id: EoKI6d_6FpA
Channel Id: undefined
Length: 13min 37sec (817 seconds)
Published: Mon Oct 16 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.