-
Notifications
You must be signed in to change notification settings - Fork 1
playground calculation
The kinects are spanning a playable field in form of a trapez but the game master as also the setup of the sounds is working with a rectangle view. To achieve that a player can collect each item on the playground the playable field has to be measured before. So what we are trying to find is the maximum rectangle in this trapez.
To achieve this we have to take a view from the top how the kinects are aligned.
Each kinect will span a triangle field in the x- and z axis which will be together the form of a trapez. If we look at one kinect at a time we can determine that the triangle will be a rectangular one if we cut it into half. We also know the maximum width (w) and depth (d) from both kinects. When the width and depth will be also divide by 2 we will have a rectangular triangle which represents a quarter of our whole playground.
The side a will represent d/2 and b is w/2.
The next step is to find here the maximum x and y value which will create the biggest rectangle possible in this triangle. To achieve this we have to calculate the maximum area of this rectangular triangle.
The formula to determine the maximum rectangle area is:
To calculate the area we need to find the correct x-value. So we need the first derivation:
After this step, we need to shift the values around to determine x.
When we input the values, in this case a = 4 and b = 5, the value for x would be 2.5 .
This x value can be put back into the maximum area equotation which will give as a result of 5 here.
Now we are only missing the value of the y-axis to determine the maximum point on the triangle.
The formula is the following:
If we connect the x and y value we have the maximum rectangle point on the diagonal side of the triangle.
If we calculate those values in reference to the other Kinects we can determine where the maximum rectangle begins and ends in the trapez.
Last but not least if you read or skipped down to this line, you can more easily approach the same result with less calculation output, which we have only discovered after this whole process.
To determine all four points to get the maximum rectangle in the trapez of the kinect you just need the following calculations:
Point | X | Y | Z |
---|---|---|---|
A | w * 0.25 | 0 | d * 0.25 |
B | w * 0.75 | 0 | d * 0.25 |
C | w * 0.75 | 0 | d * 0.75 |
D | w * 0.25 | 0 | d * 0.75 |
The positions of the ambient or collectable sounds where created unter the premise that the range goes from 0 to 1 in the x- and z-axes. Because we are working with a scaled down version of the original rectangle we need to repositioning the sound objects to the smaller rectangle.
To achieve this, we need the following calculation:
These new positions will be used in the game-master view with its relative coordinates between 0 to 1. To use these on the client-side the room size with width, depth and height has to be multiplied to the new position values.