# Level and Compass Question

Discussion in 'Scripting' started by spoonshoe, Feb 15, 2019.

1. ### spoonshoe

Joined:
Jan 25, 2010
Posts:
6
I am using the iPhone to capture slope information. There is a Level App that gives me the direction of slope and the slope percentage...see attached graphic. I want to programatically collect this information for my Unity App so I can collect slope information from the iPhone.

1. The Lat/Long give me location

2. The dataPointSlope/x, y, and z gives me gyroscope information about the slope https://developer.apple.com/documentation/coremotion/getting_raw_gyroscope_events

3. The iPhone also gives me True and Magnetic North heading information.

What is the calculation for the slope percentage and direction using the Data Point Slope x,y,z and True/Magnetic North heading?

2. ### Kurt-Dekker

Joined:
Mar 16, 2013
Posts:
3,440
Mathf.Atan2() will give you the heading (in radians) between two x,y points.

Multiplying it by Mathf.Rad2Deg will convert the result to degrees.

3. ### spoonshoe

Joined:
Jan 25, 2010
Posts:
6
Sorry if I wasn't being clear, but I don't think that's quite what I need. If you look at this image i posted, there is X euler rotation at 10.9, Y rotation is 8.92. The red 'slope' info is what I'm looking for, which is 'roughly' 13' in this image, obviously it might be off a little bit but, that's what I'm trying to acheive. Any help would be greatly appreciated. Kinda stumped on how to even describe I'm what looking for so google searches aren't helping. Thanks.

File size:
1.6 MB
Views:
36