All posts by /r/processing

I need to generate a crystal…

I need to generate a crystal...

Hello! I need to write a program which generates crystal-like forms and, believe it or not, I have no idea how to do it! I want to create something like the voronoi diagram, except much less uniform, more organic and I want to be able to distort those shapes later. How would you go about it?

I have an idea of creating shapes with vertices and they share vertex positions stored in an array (so, imagine having two squares with points ABCD and CDEF and each letter-vector is in the array), thus becoming glued together and then I would somehow distort/stretch them. Is this a good approach? I don't really know how to generate them properly so they don't look like a mess. I'd appreciate all suggestions! (I'm using p5js)

Here's a quick drawing I made by hand of what I'm going for. The faces can have less vertices.

submitted by /u/splinecharmer
[link] [comments]

Sphere Texture Array

Hi guys, I have a question. I recently found an example in processing called TextureSphere. I copied that into a sketch I made which is an array of spinning spheres. Initially, my issue was I couldn't use sphere() to texture it with an image. Now, my issue is that I have the sphere made from scratch, it textured, and it's moving, but it's super slow. Naturally. Anyway, someone told me to look into shaders and I plan to do that, but I wanted to reach out to this community and see if anyone has any suggestions for how to make this sketch run smoothly. I can share the code if needed so you can get in there and check it out. Thanks.

submitted by /u/nuserwame
[link] [comments]

Please help!

I have a project from school and I honestly don't know where to begin. I have to create a simulation and the math involved doesn't make sense to me because I'm not good at math. Could someone please help? This is the project:

There is a long-standing myth that a penny, dropped from the top of the Empire State Building, could kill a person standing on the ground below. Mythbusters has done some testing in relation to this, however, we can use a computer simulation to answer the same question. For this assigment, develop a falling simulation and use it to form an opinion about three different scenarios:

  1. A penny, dropped from the Empire State Building, lands on a person's head.
  2. A bowling ball, dropped from the Empire State Building, lands on a person's head.
  3. A person falls out of an airplane, and just before landing encounters the shockwave from an explosion

References for formulas, etc

Other Notes:

  • The area of a person is probably around half a square meter. If you search for "surface area of a person" you get numbers around 1.7 square meters, for total skin area, both sides.
  • p for air is around 1.2, but depends on the particulars. See the Wikipedia page on "density of air" for a table, "Effect of temperature on properties of air".
  • Energy required to kill someone is somewhat of a fuzzy topic. A .22 bullet weights about the same as a penny. "standard velocity" .22 rounds travel around 326 meters per second. That is enough to kill a person. So if your penny achieves a velocity of 326 meters per second, it is fast enough for sure.
  • The bowling ball will not have to move as fast as the penny to kill a person, and it will probably move much faster. It is a solid sphere. There is a note about those in the Wikipedia page on terminal velocity.

These are the notes / project description for project 2. physics: force mass // Remember, this happens every 1/60 of a second // That's 60 hertz! velocity acceleration related to force acceleration related to gravity Balance of forces, concept Air drag force Balance, in equation form Replicating skydiver results What you have to do for the project! Make three hypothesis, one for each of these three simulations: 1. penny dropped of the empire state building: Could it kill a person? 2. Same as #1, but with a bowling ball 3. A man fell out of a bomber and survived Next, create a simulation in processing that will allow you to test each of them! Finally, turn in a detailed report explaining your results, answers to each hypothesis, and your code to answer them. Basic Simulation in Processing: // Globals // These track stuff like velocity, time, etc velocity = 0; time = 0; distance = 0; // Simulation Constants downforce = ... (this is the weight, in newtons) timestep = 0.01 while(the ground has not been reached) // update each of the global variables upforce = ... (figure it out based on velocity, Cd, A, and p) totalforce = downforce - upforce; acceleration = ... (figure out from totalforce and mass) velocity += acceleration * timestep; distance += velocity * timestep; time += timestep // Now that we know all this, print a little report

submitted by /u/sbandthesextones
[link] [comments]