{"id":19901557,"url":"https://github.com/brocoo/brsuntracker","last_synced_at":"2025-05-02T23:31:51.890Z","repository":{"id":13798981,"uuid":"16494558","full_name":"brocoo/BRSunTracker","owner":"brocoo","description":"Augmented Reality classes that track and displays the sun position on the screen, available on Cocoapods","archived":false,"fork":false,"pushed_at":"2017-02-02T11:50:42.000Z","size":331,"stargazers_count":124,"open_issues_count":0,"forks_count":18,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-16T06:30:36.260Z","etag":null,"topics":["augmented-reality","gyroscope","ios","psa-algorithm","sun-position"],"latest_commit_sha":null,"homepage":"","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"AI-Productions/smelter","license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/brocoo.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-02-03T22:03:38.000Z","updated_at":"2024-12-18T11:57:19.000Z","dependencies_parsed_at":"2022-08-20T18:50:58.166Z","dependency_job_id":null,"html_url":"https://github.com/brocoo/BRSunTracker","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brocoo%2FBRSunTracker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brocoo%2FBRSunTracker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brocoo%2FBRSunTracker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brocoo%2FBRSunTracker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brocoo","download_url":"https://codeload.github.com/brocoo/BRSunTracker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252122274,"owners_count":21698305,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["augmented-reality","gyroscope","ios","psa-algorithm","sun-position"],"created_at":"2024-11-12T20:15:31.047Z","updated_at":"2025-05-02T23:31:51.386Z","avatar_url":"https://github.com/brocoo.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BRSunTracker\n\nBRSunTracker is a set of classes using [Augmented Reality] that allow you to track and display the position of the sun on your device screen, based on your current GPS location, the device gyroscope, the time and the date.\n\nThe position of the sun in the sky is computed via the PSA Algorithm, and its position on the screen uses the device rotation matrix provided by the gyroscope (See \"How does it work?\" section below).\nBRSunTracker also works during the night, just aim at your feet to find to find the sun.\n\nThe sample app included displays a marker on a camera preview that follows the sun on the screen and snaps to the middle of the view once the phone is oriented towards it.\n\n![http://i.imgur.com/RyTVnY6.png](http://i.imgur.com/RyTVnY6.png)\n![http://i.imgur.com/UbxsJs5.gif](http://i.imgur.com/UbxsJs5.gif)\n\n## Installation\n\nBRSunTracker is available through [CocoaPods](http://cocoapods.org), to install\nit simply add the following line to your Podfile:\n\n    pod \"BRSunTracker\"\n    \n## Usage\n\n1.  Import the `BRSunTrackerView` class into your view controller:\n\n  ```objective-c\n    #import \"BRSunTrackerView.h\"\n  ```\n  \n2.  Instanciate `BRSunTrackerView` and add it as a subview.\n  ```objective-c\nBRSunTrackerView *sunTrackerView = [[BRSunTrackerView alloc] initWithFrame:CGRectMake(0, 0, 320, 428)];\n[self.view addSubview:sunTrackerView];\n  ```\nOr you can also add a `BRSunTrackerView` directly via the Interface Builder.\n\n3.  By default, the `BRSunTrackerView` will display a camera preview, and a default marker following the sun. \nYou can enable or disable the camera and provide your own UIView as a marker by setting these properties:\n  ```objective-c\n    // Enable or disable the camera preview\n    // (The default value is YES)\n    [sunTrackerView setDisplayCameraPreview:YES];\n\n    // Provide your own marker subview \n    // (otherwise will display the default one)\n    [sunTrackerView setSunView:myMarkerView];\n  ```\n4. (Optional) Set your view controller as the delegate of the `BRSunTrackerView` and make it conform to the `BRSunTrackerViewDelegate` protocol. Implement the following methods to detect when the phone is aligned with the sun:\n\n  ```objective-c\n    [sunTrackerView setDelegate:self];  \n  ```\n  \n  ```objective-c\n    - (void)sunTrackerViewGotFocus:(BRSunTrackerView *)sunTrackerView{\n        NSLog(@\"The sun is aligned with the device.\");\n    }\n    \n    - (void)sunTrackerViewLostFocus:(BRSunTrackerView *)sunTrackerView{\n        NSLog(@\"The sun is not aligned with the device anymore.\");\n    }\n  ```\n5. Grab a pair of sunglasses (and a cold drink).\n\n\n## How does it work?\n\nA diagram explaining roughly the process of computing the sun 2D screen coordinates in BRSunTracker is shown below.\nAll of this happens inside the `BRSunTracker` class.\nThe gyroscope orientation data is currently sampled 60 times per second, the sun spherical coordinates are computed every minute or when the GPS location gets updated.\n\n![http://i.imgur.com/aF1SeW5.png](http://i.imgur.com/aF1SeW5.png)\n\n## Sources and acknowledgements\n\n[pARk], Apple code sample showing a basic Augmented Reality implementation\n\n[PSA Algorithm], C++ function that computes the spherical coordinates of the sun based on the GPS coordinates, the time and date.\n\n[Stack Overflow], My initial Stack Overflow post about how to compare the device orientation with the sun position.\n\nThanks to Dan Marson who provided the GIF shown above.\n\nThis feature was conceived and built for the \"Piano Ombre\" album-app concept for Frànçois and the Atlas Mountains, now available on the [App Store].\n\n## Author\n\nJulien Ducret - \u003cbrocoo@gmail.com\u003e\n\nFollow me on Twitter [@jbrocoo](https://twitter.com/jbrocoo)\n\nCheck out my app: [Spores](https://itunes.apple.com/us/app/spores/id718495353?l=fr\u0026ls=1\u0026mt=8)\n\n## Licence\n\nBRSunTracker is under Apache licence, see the LICENCE file for more info.\n\n[Augmented Reality]:http://en.wikipedia.org/wiki/Augmented_reality\n[PSA Algorithm]:http://www.psa.es/sdg/sunpos.htm\n[pARk]:https://developer.apple.com/library/ios/samplecode/pARk/Introduction/Intro.html\n[Stack Overflow]:http://stackoverflow.com/questions/21246745/compare-device-3d-orientation-with-the-sun-position\n[App Store]:https://itunes.apple.com/gb/app/piano-ombre/id840099884?mt=8\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrocoo%2Fbrsuntracker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrocoo%2Fbrsuntracker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrocoo%2Fbrsuntracker/lists"}