Skip to content

ajan890/174C-Plane-Simulation

Repository files navigation

Banner Plane Simulation

Team:

  • Mubai Hua: 905 571 231
  • Austin Chuang: 905 377 658
  • Lukas Brockenbrough: 505 620 894
  • Aidan Jan: 805 684 752

Overview

The simulation is of a plane carrying a banner. The user can:

  • define a plane’s path by editing the spline’s control points
  • manually adjust the velocity of the plane in real-time, or set the plane to use the velocities as defined by the spline
  • manually adjust the plane’s rotation
  • change the weather conditions of the scene
  • display/hide spline, axes, or banner particles

How to Run

  • Press the Draw button, then Start!
  • Here is a brief summary of what all the buttons do:
    • Spline:
      • See details below
    • Config:
      • Start: starts the animation
      • Pause: pauses the animation
      • Stop: stops and resets the animation
    • Weather:
      • Sunny: switches to clear weather
      • Rain: switches to rainy weather
      • Snow: switches to snowy weather
    • Velocity:
      • -velocity: decreases velocity of plane (if in independent velocity mode)
      • ind_velocity: toggles between independent velocity and automatic velocity
      • +velocity: increases velocity of plane (if in independent velocity mode)
    • Roll:
      • roll_left: rolls the plane to the left (toggle button)
      • roll_reset: resets the roll of the plane to the default position
      • roll_right: rolls the plane to the right (toggle button)
    • Rendering:
      • Toggle Spline: toggles the rendering of the spline
      • Toggle Banner Particles: toggles the rendering of the banner particles
      • Toggle Axes: toggles the rendering of the world axes
    • Wind:
      • Change Wind Vector: allows the user to manually change wind vectors
      • The format of the wind vector should be 1, 1, 1, representing the 3d vector of wind force Vectors are separated by new lines, and the total number of lines represents the total number of wind sections in the scene.. For example, if there are two 3d wind vectors, the upper half of the scene will have wind in the first vector, and the lower half of the scene will have wind in the second vector

Spline Editor Interface

  • When the animation is in default state (background color is black), the user can access three modes for editing the spline: "Add Point", "Adjust Point", and "Delete Point". In each mode, the spline resulting from the proposed change is a different color.
  • Back: exits the current spline editing mode
  • Add Point:
    • The user can adjust a new point
    • The default new point is (0, 0, 0, 1, 1, 1)
    • The current point entry (x, y, z, vx, vy, or vz) being edited is displayed
      • --: Changes the current point entry by -0.5 or -2
      • -: Changes the current point entry by -0.1 or -0.4
      • +: Changes the current point entry by 0.1 or 0.4
      • ++: Changes the current point entry by 0.5 or 2
    • Toggle Point Entry: Toggles the point entry being edited
    • Add Point: Adds the new point
  • Adjust Point:
    • The user can adjust an existing point
    • Toggle Point: Toggles the point being adjusted
    • By default, the point is adjusted to (0, 0, 0, 1, 1, 1)
    • The current point entry (x, y, z, vx, vy, or vz) being edited is displayed
      • --: Changes the current point entry by -0.5
      • -: Changes the current point entry by -0.1
      • +: Changes the current point entry by 0.1
      • ++: Changes the current point entry by 0.5
    • Toggle Point Entry: Toggles the point entry being edited
    • Adjust Point: Adjusts the point
  • Delete Point:
    • The user can delete an existing point
    • Toggle Point: Toggles the point being deleted
    • Delete Point: Deletes the point

Implementations

Cloth Simulation

The cloth is created using a spring-damper matrix, following a guide written by Jesper Mosegaard (link in Resources section)

Because the plane’s velocity is very small relative to its size, it makes considerably sharper turns than would be possible in real life.

  • This is a limit of the renderer - to make it realistic, the plane and banner either have to be much smaller and faster or the spline much bigger To prevent the banner from flying away or spinning out of control, many extra features were added:
  • For Each tick a velocity vector is added directly to the particles to keep it moving with the plane, rather than the plane dragging the banner along.
  • A spring with very high elastic and damper constants connects the top-left and bottom-left particles, which prevents the banner from rolling up. This is similar to adding a rigid cylinder, such as a steel or fiberglass rod to the edge of the banner in real life.
  • A wind force in the opposite direction to the plane’s velocity is added in an attempt to keep the banner flowing behind the plane, and not to the sides
    • The banner has two (invisible) points defined by the plane’s position that the front of the banner is linked to, which slowly negates any force from the banner spinning at an unnatural angle.
  • To apply a more realistic wind force than just applying a force to all particles equally, the wind force is calculated using the normals of the triangles formed by the particles
  • Rain and snow do not have a collision with the banner - in real life, the plane and banner move so fast compared to the tiny particles that their collision is negligible.

Weather Simulation

  • The weather simulation is implemented as a particle system. The particles are generated at random locations over an area above the plane, and each particle will have a mass, acceleration, velocity, and drag coefficient. The initial acceleration vector of the particle will be the gravity of the earth, (0, -9.8, 0). As the particle falls to the ground, it will have air resistance force acting on it in the opposite direction of the gravity force, decreasing its acceleration in the y-axis until an equilibrium is achieved and the particle falls at a constant speed in the y-axis.

  • The air resistance is calculated from the particle’s speed, using the formula F = k*v^2, and different weather particles will have different air resistance coefficients. For instance, snow particles will have much larger air resistance coefficients than rain particles.

  • The wind system in the weather simulation is implemented as a vector field. The wind force is set at different altitudes as a 3d vector and will be applied to the weather particles. There is also air drag force acting on the particle to balance the wind force, and snow and rain particles will also have different air resistance coefficients.

Plane Simulation

  • Calculates a local frame at every position on the spline using tangent, second derivative(converted to curvature) for normal, and tangent cross normal to get the binormal.
    • Initially calculated the rotation matrix between prev_tangent and next_tangent, which resulted in no control over the rotation of the plane.
    • started with a Frenet Frame implementation and swapped to a Rotation Minimizing Frame, since it could handle discontinuous curvature.
    • The Rotation Minimizing Frame has little rotation, which allows finer control over the local roll of the plane if adjustments are desired(can be done with a custom curve like a 2d spline).
      • Unlike the Frenet Frame which only needs to store current values, The rotation minimizing frame stores the previous T, N, B values so it can calculate the new transform(TNB frame) relative to the previous values.
      • Uses the double reflection method to calculate N and B
      • Recalculating the N, B vectors additional time is required to account for precision errors(making sure the vectors are orthogonal).
    • Rotation curve can be defined with a 2d spline if required and passing y value into the rotation function.
    • can change the desired frame object by changing the object in airplane.update_state(...).
  • Independent Velocity/Arc Length parameterization
    • Using the arc length table, binary search on arc length to get the index that corresponds to the position on the current spline.
    • Find the arc length that you have interpolated on the current section of the spline and the length of the same section of the spline. Calculate the interpolation value for the spline that you are currently on.
      • Edge cases where distance traveled/velocity skips over a spline is handled.
      • velocity is clamped to avoid precision errors if decreased too much.
  • Simulating the motion of the airplane with a banner.
    • To prevent unstable behavior of the banner, a percentage of the plane velocity is applied to the banner, so it can simulate the pulling of the banner while maintaining the stability of the spring/dampers in the cloth.

Algorithms

  • Splines
  • Motion Curves
    • Frenet Frame
    • Rotation Minimizing Frame
    • Arc Length Parameterization
  • Spring-Damper Systems
  • Physics-based particle simulation
    • Particle Seeding
    • Air resistance and Friction calculations

Resources

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages