# ARKit and CoreLocation: Part One

## Navigation With Linear Algebra (and Trig)

Aug 26, 2017 · 10 min read
`Demo CodeARKit and CoreLocation: Part OneARKit and CoreLocation: Part TwoARKit and CoreLocation: Part Three`

# Introduction

Augmented reality (AR) describes user experiences that add 2D or 3D elements to the live view from a device’s camera in a way that makes those elements appear to inhabit the real world. ARKit combines device motion tracking, camera scene capture, advanced scene processing, and display conveniences to simplify the task of building an AR experience.

# First, Some Fundamentals

## Definitions

`worldAlignment: The worldAlignment property on ARSession defines how the ARSession interprets the ARFrame’s motion data on a 3D coordinate mapping system that is uses to keep track of the world and build the Augmented Reality experience.`
`gravity: By setting the alignment to gravity ARKit aligns the y-axis parallel to gravity and the z and x axes are oriented along the original heading of the device.`
`gravityAndHeading: By setting the alignment to gravityAndHeading ARKit aligns the y-axis parallel to gravity and the z and x axes orient towards compass heading. The origin is placed at the initial location of the device. While this is accurate most of the time, it’s precision is not incredibly high so creating an immersive augmented reality experience while solely relying on this data can be tricky.`

# SceneKit

## SphereNode Sphere Code

`sceneView.scene = SCNScene()        // Add Scenelet circleNode = createSphereNode(with: 0.2, color: .blue)  // Add Sphere     circleNode.position = SCNVector3(0, 0, -1) // 1 meter in front // Give sphere position       sceneView.scene.rootNode.addChildNode(circleNode)// Add to scene as childNode of rootNode`

# Vectors and Matrice and Linear Algebra, Oh No!

In mathematics, physics, and engineering, a Euclidean vector (sometimes called a geometric or spatial vector, or — as here — simply a vector) is a geometric object that has magnitude (or length) and direction.

# Transformations

`Transformed Point = Transformation Matrix × Original Point`

# Rotating A Space Ship

## Definitions

`print(route.name)// Broadwayprint(route.advisoryNotices)// []print(route.expectedTravelTime)// 2500.0`
`print(step.distance)// 1.0print(step.instructions)// Proceed to 7th Ave`

Written by

Written by