Physical Engine Interface

Source: Internet
Author: User

' Michael Zhu Date: January 06, 2017

1 Structural analysis 1.1 class definitions
    • Hockey Class: Class Puck
    • Ball Table class: Class table
    • Batter class: Class Hockey_stick
1.2 Key functions

According to the above class, and the following requirements:

Input: The current position and speed of the batter (controlled by the robot). Output: The current position and speed of the puck. It is known that the key functions are collision detection and velocity calculation after collisions. One of the difficulties is collision detection.

    • void Check_collision ();//Check for collisions
    • void Update_position ();//Update location
    • void Update_velocity ();//update speed
2 Interface Design

The physics engine is a relatively independent piece that simply provides a simple interface to the GUI and policy.

2.1 Algorithm Interface
    • void Puckstep ();//Update physical state
2.2 Data Interface

Hockey:

    • Double radius;
    • Double Position[axis_count];
    • Double Velocity[axis_count];
    • Double mass; Corresponds to a parameter in common and passes the argument to the variable in common each time.

Ball Table:

    • Double length;
    • Double width;
    • Double goalline1;
    • Double Goalline2;

Ball Sticks:

    • Double radius;
    • Double mass;
    • Double Pre_position[axis_count], Cur_position[axis_count];
    • Double Velocity[axis_count]; The above is the parameter in the class.

    • static double Default_puck_radius = 0;

    • static double default_puck_mass = 0;

    • static double default_table_length = 0;

    • static double default_table_width = 0;

    • static double Default_hockey_stick_radius = 0;

    • static double default_hockey_stick_mass = 0;

    • static double default_goal_length1 = 0;

    • static double default_goal_length2 = 0; The above parameters are preset values, and other modules can be used directly.

Physical Engine Interface

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.