Skip to content

playground calculation

Kono14 edited this page Sep 25, 2016 · 2 revisions

Calculation of the useable playground

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.

kinect_overview

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.

triangle1

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.

triangle2

The formula to determine the maximum rectangle area is:

maxArea_formula

To calculate the area we need to find the correct x-value. So we need the first derivation:

firstDerivation

After this step, we need to shift the values around to determine x.

umstellen

When we input the values, in this case a = 4 and b = 5, the value for x would be 2.5 .

ausrechnen

This x value can be put back into the maximum area equotation which will give as a result of 5 here.

area_calc

triangle3

Now we are only missing the value of the y-axis to determine the maximum point on the triangle.

The formula is the following:

formula_y

If we connect the x and y value we have the maximum rectangle point on the diagonal side of the triangle.

triangle4

If we calculate those values in reference to the other Kinects we can determine where the maximum rectangle begins and ends in the trapez.

playground

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.

easyCalc

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

Scaling of sound positions

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:

formula_scalePositions

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.

Clone this wiki locally