Look at your data!
CSV vs TSV is best decided by whether your data has commas in it.
If commas, use TSV (so you can't get confused between a data comma and a separator comma).
Yes, just cite yourself in a comment.
Yes, though the final project has different requirements so you can't just submit Project 6 verbatim.
It would be more accurate to say that Python does not have an equivalent to Java arrays: all list operations in Python are slow.
What program can display JSON files in an orderly manner?
Are file extensions (e.g. '.csv', '.txt') used to determine how to load a file?
Only if the programmer decides to do so.
Floating-point accuracy introduces some nasty wrinkles into implementations.
Sphere-Sphere
Box-Box
Triangle-Triangle
The shortest path between the two centers is a line. If the length of this line is less than the sum of the radii, they're colliding.
Sphere 1 located at \((x_1, y_1, z_1\)) with a radius of \(r_1\).
Sphere 2 located at \((x_2, y_2, z_2\)) with a radius of \(r_2\).
Spheres are colliding if
Box 1 centered at \((x_1, y_1, z_1\)) with axial sizes of \(h_1\), \(w_1\), \(d_1\).
Boxes are not colliding if any of the following are true
Box 2 centered at \((x_2, y_2, z_2\)) with axial sizes of \(h_2\), \(w_2\), \(d_2\).
So boxes are colliding if all of the above are false.
This is a topic that's highly, highly studied. Many papers on the topic, not all of them correct.
Also a little funky: we're trying to check if 2D shapes collide in 3D, but they don't have to be in the same plane!
This method is slow, but relatively foolproof. There are faster methods, but these often have issues in floating point math, or miss certain edge cases.
We can just intersect the triangles against each other!
boolean shapesIntersect(Shape s1, Shape s2){
for(int i = 0; i < s1.tri.length; i++){
for(int j = 0; j < s2.tri.length; j++){
if( s1.tri[i].intersects(s2.tri[j])){
return true;
}
}
}
return false;
}
At 3 GHz, this is about 25 minutes.
Suppose we have a scene with \(N\) objects. How many potential collisions are there?
Of those, how many do we expect to see actually occurring at any point?
Separate our collision check into two phases:
We need a check that satisfies the following:
If the spheres do not intersect, the objects definitely do not intersect.
Sphere intersection is fast to compute.
If the spheres intersect, the objects might intersect. Proceed to narrow-phase.
More common for certain applications: AABBs.
A way to organize shapes by their location.
Similar idea to scene hierarchy, but tracks locations rather than transformation.
The structure we have examined above is a quadtree. The 3D analogue structure is known as an octtree.
There are also other spatial data structures:
we're going to deal with rigid bodies.
Option 1: Move the colliding shapes away from each other a small distance and restart the simulation.
Option 1: Move the colliding shapes away from each other a small distance and restart the simulation.
Yeah, this doesn't look great.
Other issues:
Option 2: Go for a completely inelastic collision: all velocity in the collision direction is immediately lost.
Option 2: Go for a completely inelastic collision: all velocity in the collision direction is immediately lost.
This is actually acceptable under certain situations!
For example, if we have a player character that is falling to the ground, we probably don't want to make them rebound into the sky.
Resolving all collisions this way leads to an unrealistic world.
Option 3: Apply a force in the normal direction of the collision until the collision would no longer take place on the next timestep.
Option 3: Apply a force in the normal direction of the collision until the collision would no longer take place on the next timestep.
Next frame with no force
Option 3: Apply a force in the normal direction of the collision until the collision would no longer take place on the next timestep.
Next frame with small force
Option 3: Apply a force in the normal direction of the collision until the collision would no longer take place on the next timestep.
Next frame with larger force
Option 3: Apply a force in the normal direction of the collision until the collision would no longer take place on the next timestep.
Next frame with even larger force
This force is sufficient to prevent the collision on this frame, so we apply this force to the ball and to the stand (Newton's Third Law)
Option 3: Apply a force in the normal direction of the collision until the collision would no longer take place on the next timestep.
What effect does this force have on the next few timesteps of simulation?
Option 3: Apply a force in the normal direction of the collision until the collision would no longer take place on the next timestep.
What effect does this force have on the next few timesteps of simulation?
Option 3: Apply a force in the normal direction of the collision until the collision would no longer take place on the next timestep.
What effect does this force have on the next few timesteps of simulation?
We don't actually have to try larger and larger forces until we find one that works---the language of impulses in classical mechanics allows us to compute the correct force to apply.
We get stuck in an infinite loop of applying impulses!
State of the art: if we spend too long trying to resolve collisions, give up.
Allow the collision to go unresolved: will look ugly and break the system, but (probably?) better than a guaranteed lockup of the system.
There are tons of other ideas and fields in collision detection. For example, we have not discussed:
This field is very deep and rich. What we've seen today barely scratches the paint!
HINT: It may help to change your drawing mode.
Yes, I'll make that list once I have an idea of who's in what groups.
Yes.
In most 3D games/settings, UIs are still 2D things drawn on top of the 3D world.
In VR (3D worlds), UIs are very much still experimental, and we don't know what form they'll take yet.
Can either use a UI toolkit or use 2D drawing calls in a 3D environment.
RectangularButton b;
CircularButton c;
pushMatrix();
translate(200, 0, 0);
rotateY(angle / 2);
shape(box);
popMatrix();
popMatrix();
hint(DISABLE_DEPTH_TEST);
b.draw();
c.draw();
hint(ENABLE_DEPTH_TEST);
https://github.com/KrabCode/LazyGui
Not really, no. Although depending on a developer's role within a team, they may be assigned to fix bugs more often than writing new functionality (or vice versa).
Debuggers are primitive scripting interfaces that interact with your code at runtime. You can do all sorts of stuff with them.
Stop on line 27, but only when
var
is 15 andtimer
is odd. Then print out the largest element oflist7
and tell me if it's larger or smaller thanflorp
.
But these are advanced tricks.
Two General Styles:
What functionality is common and what is different between the two button types?