Skip to content

Commit

Permalink
Removed camera angles addition to position of turbah calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
qazwini committed Aug 1, 2020
1 parent 86bee02 commit 73c14bf
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 27 deletions.
Binary file added .DS_Store
Binary file not shown.
Binary file not shown.
Binary file added Turbah/.DS_Store
Binary file not shown.
27 changes: 11 additions & 16 deletions Turbah/Controllers/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ class ViewController: UIViewController, CLLocationManagerDelegate, ARCoachingOve
setupUI()
showCalibrateView()
initManager()
addCoaching()
}

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
if didAddCoaching { arView.run() }
if didRun { arView.run() }
}

override func viewWillDisappear(_ animated: Bool) {
Expand Down Expand Up @@ -97,16 +98,12 @@ class ViewController: UIViewController, CLLocationManagerDelegate, ARCoachingOve

let decreaseValue = 6 - save.distance

anchor.position.z = -1 * cos(Float(bearingOfKabah)) / decreaseValue + cameraAngles.z
anchor.position.x = sin(Float(bearingOfKabah)) / decreaseValue + cameraAngles.x
// Is Y adjustment needed?
//anchor.position.y += cameraAngles.y
anchor.position.z = -1 * cos(Float(bearingOfKabah)) / decreaseValue
anchor.position.x = sin(Float(bearingOfKabah)) / decreaseValue
anchor.position.y = 0
print("after", anchor.position)

let x = sin(Float(bearingOfKabah)) / decreaseValue + cameraAngles.z
let z = -1 * cos(Float(bearingOfKabah)) / decreaseValue + cameraAngles.x

print("angle", atan(x/z) * 180 / .pi)
print("angle", atan(anchor.position.x/anchor.position.z) * 180 / .pi)

let anchorAngles = anchor.transform.matrix.columns.3

Expand Down Expand Up @@ -157,7 +154,7 @@ class ViewController: UIViewController, CLLocationManagerDelegate, ARCoachingOve

return
}
if !didAddCoaching { addCoaching() }
if !didRun { arView.run() }
arView.run()
}

Expand Down Expand Up @@ -343,7 +340,7 @@ class ViewController: UIViewController, CLLocationManagerDelegate, ARCoachingOve
}

var didSendFeedback = false
var didAddCoaching = false
var didRun = false

func locationManager(_ manager: CLLocationManager, didUpdateHeading heading: CLHeading) {
let chosenHeading = save.trueNorth ? heading.trueHeading : heading.magneticHeading
Expand Down Expand Up @@ -371,7 +368,7 @@ class ViewController: UIViewController, CLLocationManagerDelegate, ARCoachingOve
} else {
if !didSendFeedback {
hapticFeedback(style: .medium)
if !didAddCoaching { addCoaching(); didAddCoaching = true }
if !didRun { arView.run(); didRun = true }
didSendFeedback = true
}
leftImage.alpha = 0
Expand All @@ -390,12 +387,10 @@ class ViewController: UIViewController, CLLocationManagerDelegate, ARCoachingOve

view.addSubview(coachingOverlay)
coachingOverlay.fillSuperview()

arView.run()
}

public func coachingOverlayViewWillActivate(_ coachingOverlayView: ARCoachingOverlayView) {
didAddCoaching = true
didRun = true
UIView.animate(withDuration: 0.2) {
self.compassView.alpha = 0
self.settingsButton.alpha = 0
Expand All @@ -411,7 +406,7 @@ class ViewController: UIViewController, CLLocationManagerDelegate, ARCoachingOve
self.locationButton.alpha = 1
}

guard didSendFeedback, selectedLocation == .kabah else { return }
//guard didSendFeedback, selectedLocation == .kabah else { return }
placeTurbah()
}
}
Expand Down
4 changes: 2 additions & 2 deletions Turbah/ar.lproj/InfoPlist.strings
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
*/

"CFBundleDisplayName" = "تربة";
"NSCameraUsageDescription" = "";
"NSLocationWhenInUseUsageDescription" = "";
"NSCameraUsageDescription" = "منح الصلاححية لتشغيل الواقع المعزز";
"NSLocationWhenInUseUsageDescription" = "منح الصلاححية لتشغيل البوصلة";
12 changes: 6 additions & 6 deletions Turbah/ar.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@
"OurApps" = "تطبيقاتنا";
"TermsPrivacy" = "الشروط وسياسة الخصوصية";
"Share" = "المشاركة";
"EmailTitle" = "تربة AR قبلة";
"EmailTitle" = "تربة";
"UnableSendTitle" = "لا يمكن إرسال الرسالة";
"UnableSendMessage" = "لا يمكن إرسال الرسالة. الرجاء التأكد من اتصال الإنترنت، ثم حاول مرة اخرى.";

"Settings" = "الإعدادات";
"Retry" = "إعادة المحاولة";

"FaceQiblaMessage" = "يرجى مواجهة القبلة ثم اضغط";
"FaceQiblaMessage" = "رجاء واجه القبلة ثم اضغط";

"RerunTitle" = "";
"RerunMessage" = "";
"RerunTitle" = "اضغط لإعادة التشغيل";
"RerunMessage" = "سيؤدي النقر على هذا الزر إلى المعايرة ثم وضع التربة";
"Ok" = "حسنا";

"LocationDisabled" = "";
"CameraDisabled" = "";
"LocationDisabled" = "خدمات الموقع معطلة";
"CameraDisabled" = "صلاحيات الكامرة معطلة";
4 changes: 1 addition & 3 deletions Turbah/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,14 @@
"SayedahMasumaShrine" = "Sayedah Ma'suma Shrine";
"SayedahZainabShrine" = "Sayedah Zainab Shrine";


"Settings" = "Settings";
"Contact" = "Contact";
"TurbahDistance" = "Turbah distance";
"TrueNorth" = "True North";
"MagneticNorth" = "Magnetic North";
"OurApps" = "Our apps";
"TermsPrivacy" = "Terms and Privacy Policy";
"Share" = "Share";
"EmailTitle" = "Turbah AR Qibla";
"EmailTitle" = "Turbah";
"UnableSendTitle" = "Unable to send message";
"UnableSendMessage" = "Unable to send message. Please check your internet connection and try again.";

Expand Down

0 comments on commit 73c14bf

Please sign in to comment.