2/28/2023 0 Comments Light intensity formula![]() > light_grid = light_universe(7, 32, stars, 1) Stars are represented in tables of the form: stars = Here is some Lua code that implements this. To calculate another wrap, add another layer of copies. To find the light intensity for one wrap at the green square, add the simple intensities calculated at each of the blue squares to the simple intensity calculated for the green square. In the above diagram, the black grid represents the world, and the blue grid represents the copies of the world grid. For each square in the original grid, calculate the light intensity that falls on each corresponding square, and sum the results. ![]() You can solve this by imagining that the grid is surrounded by copies of the original grid, one layer for each wrap. of each square? (Given that the function takes in the x and y coordinate of one square and one sun, and the width and height of the world, what would be the return of the given square's R.I. So, what should the new function be for calculating the R.I. This not only need to apply to other objects in the simulation, but also light. This is all well and good, until I felt the need to introduce a warping mechanic to this simulation: objects that move "outside" the edge of the world will "re-enter" the world from the other side, like in the game Asteroid. for each sun will be calculated separately and added together for each square. and, to accommodate multiple suns, the R.I. may look like this: (define (calc-RI sq-x sq-y sn-x sn-y) Written in a generic(and terrible) programming language, a function that calculates R.I. = 100 / (distance between light source and square)^2 In this image, the distance between the centres of squares is 32 units, and the received intensity (or R.I.) of each square is calculated with this formula: There are also objects designated as "suns", which illuminate the squares and update their "received intensity" each step. I am building a simulation in which there is world made of many squares.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |