add docs
This commit is contained in:
parent
4461eb428b
commit
1a880cecae
6
Develop.md
Normal file
6
Develop.md
Normal file
@ -0,0 +1,6 @@
|
||||
## Developer Guide
|
||||
|
||||
### Building & Deployment
|
||||
- open the project in XCode
|
||||
- connect your iPhone and set it to developer mode
|
||||
- build and deploy the app to your iPhpne
|
65
How.md
Normal file
65
How.md
Normal file
@ -0,0 +1,65 @@
|
||||
## How does it work?
|
||||
|
||||
The underlying mathematical principal used is trigonometry. It assumes, that a reference height is known. This could be a stick of a known length leaned against the tree as optical marker, or an actual marker on the tree at a known height. Given that known height, the height of the entire tree can be calculated without actually knowing the distance to the tree.
|
||||
|
||||
The implementation was inspired by the formulas and explanations given at the [AWF-Wiki of University of Göttingen](http://wiki.awf.forst.uni-goettingen.de/wiki/index.php/The_trigonometric_principle). They present the following formulas in more detail and with nice pictures, so go there to learn more!
|
||||
|
||||
### Definitions for the calculation
|
||||
|
||||
- $l$: the reference height in meters,
|
||||
- $e$: the distance to the tree in meters
|
||||
- $\alpha1$: the angle between horizontal line and top of tree,
|
||||
- $\alpha2$: the angle between horizontal line and bottom of tree,
|
||||
- $\alpha3$: the angle between horizontal line and top of reference height
|
||||
|
||||
### Formulas and Calculations
|
||||
The reference height $l$ can be calulated like this:
|
||||
|
||||
$l = e * (tan (\alpha 1) - tan(\alpha 2))$
|
||||
|
||||
By transforming the formula (with given $l$), the distance to the tree can be caculated like so:
|
||||
|
||||
$e = \frac{l}{tan (\alpha 1) - tan(\alpha 2)}$
|
||||
|
||||
The actual tree height $h$ is constructed of
|
||||
|
||||
- $h1$: the distance between horizontal and top of tree, and
|
||||
- $h2$: the distance between horizontal and the bottom of the tree
|
||||
|
||||
and can be calculated as such:
|
||||
|
||||
$h = h1 - h2$
|
||||
|
||||
$h1 = e * tan(\alpha1)$
|
||||
|
||||
$h2 = e * tan(\alpha2)$
|
||||
|
||||
Thus, with the formula for $e$, we get the following final formula.
|
||||
|
||||
$h = h1 - h2 = (e * tan(\alpha1)) - (e * tan(\alpha2))$
|
||||
|
||||
$= \frac{l}{tan (\alpha 1) - tan(\alpha 2)} * tan(\alpha1) - \frac{l}{tan (\alpha 1) - tan(\alpha 2)} * tan(\alpha2)$
|
||||
|
||||
### Considerations in implementation
|
||||
To get correct results, the following things have additonally been implemented.
|
||||
|
||||
#### Corrections for display in degrees
|
||||
When using the integrated motion sensors, the iPhone measures angles in radians. When converting those to degrees, they will repeat when looking down or up (as they are the "difference" to the horizontal line). So we must determine if we are actually looking "up" or "down" (using the gravity "z" angle of the motion sensor) and apply a transformation.
|
||||
|
||||
This was done like this:
|
||||
|
||||
a) First, convert to degrees:
|
||||
|
||||
$\alpha1(deg)=alpha1(rad) * \frac{180}{\pi}$
|
||||
|
||||
b) next, if we are looking "up", tranform it to be the correct angle:
|
||||
|
||||
$\alpha1(deg) = 180 - alpha1(deg)$
|
||||
|
||||
#### Angle corrections to allow all possibilities of tree location
|
||||
Depending on whether the different angles are located - above or below the horizontal line - (when the iPhone is hold in portrait orientation, these are - in degrees - 90°) the angles have to be multiplied by `-1` as needed
|
||||
- if looking "up", multiply by `-1`, if looking down, keep the original radian value.
|
||||
|
||||
#### Corrections for negative values
|
||||
Depending on whether certain angles are above or below the horizontal line one would get negative values in some cases. This is why at many places I used `abs` to only get the numbers in a positive range.
|
||||
|
8
Readme.md
Normal file
8
Readme.md
Normal file
@ -0,0 +1,8 @@
|
||||
# iOS Tree Height Measuring App
|
||||
This repository contains an App for iOS written in Swift to measure the height of trees (or any other object).
|
||||
|
||||
|
||||
## Contents
|
||||
- [User Guide](UserGuide.md)
|
||||
- [How does it work?](How.md)
|
||||
- [Developer Guide](Develop.md)
|
25
UserGuide.md
Normal file
25
UserGuide.md
Normal file
@ -0,0 +1,25 @@
|
||||
## User Guide
|
||||
|
||||
### Before starting - prepare reference height
|
||||
When you selected a tree for measurement you first need to optically mark a reference height on it. You could do this by using a stick of a known length and leaning it at the tree. Or you could mark the height with any kind of marker. Make sure that you can see the marker from an comfortable distance - you should be able to see both easily: the marker and the top of the tree. It is recommended to get as close as possible to the tree to get the most accurate measurements.
|
||||
|
||||
### Taking measurements
|
||||
The calculation needs 3 measurements taken using the marker at the center of your screen.
|
||||
|
||||
#### Marker 1: Top of reference height
|
||||
First, mark the top of the reference height. To do so, place the top of the reference height as accurately as possible at the marker at the center of your screen. Try not to shake too much as to not disturb the motion sensor of your phone too much.
|
||||
|
||||
When you are ready, take the mark using the "shutter" button at the bottom of your screen.
|
||||
|
||||
#### Marker 2: Bottom of tree
|
||||
For the second measurement, mark the bottom of the tree the same way as you took the first measurement.
|
||||
|
||||
You should now see the calculated distance to the tree. If you notice a unplausible result already, start over by clicking the "reset" button.
|
||||
|
||||
#### Marker 3: Top of tree
|
||||
Finally, take a measurement of the top of the tree the same way you took the other measurements.
|
||||
|
||||
The result is now presented at the top of the screen.
|
||||
|
||||
### Restart measuring
|
||||
You can at any time start over using the "reset" icon.
|
Loading…
x
Reference in New Issue
Block a user