NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

/******************************************************************************************
* Autor: Toto
* Objetivo: Esta clase es la responsable de obtener los datos del GPS y lo mappea a la U3D
* Fecha: 07/09/14
* ***************************************************************************************/


using UnityEngine;
using System.Collections;
using System;

public class GPSManager : MonoBehaviour
{

private double puntoGpsLat;
private double puntoGpsLon;
private int frame = 0;

//Variables para el mapeo
public static double resultadoX=0,
resultadoY=0;

//Constantes para el mapeo

private double puntoCeroX = -37.321306,
puntoCeroY = -59.079523;

private double cosenoAng = 0.9297764821, // Es el resultado de: seno( gradosaRadianes(21.6°) );
senoAng = 0.3681245623; // Es el resultado de: coseno ( gradosaRadianes(21.6°) );

private double factorEscala = -91000,
escalaCompX = 1.05,
escalaCompY = 1.22;

/// ************************************ ///

IEnumerator Start()
{
georeferencing();
if (!Input.location.isEnabledByUser)
yield return false;

Input.location.Start();
int maxWait = 20;
while (Input.location.status == LocationServiceStatus.Initializing && maxWait > 0){
yield return new WaitForSeconds(1);
maxWait--;
}

if (maxWait < 1){
GetComponent<TextMesh>().text = "Timed out";
return false;
}
}

// Update is called once per frame
void Update (){

if (frame == 30){
if (Input.location.status == LocationServiceStatus.Failed) {
GetComponent<TextMesh> ().text = "Unable to determine device location";
}
else{
georeferencing ();
}
this.frame = 0;
} else {
this.frame++;
}
}

void georeferencing(){

double aux1, aux2;

puntoGpsLat = Input.location.lastData.latitude; //-37.323022;
puntoGpsLon = Input.location.lastData.longitude; //-59.082733;

/*
float[][] scores = new float[3][10];
*/

aux1 = transf_Long_a_U3d();
aux2 = transf_Lati_a_U3d();

if ((aux1 < 200 && aux1 > -250) && (aux2 < 500 && aux2 > -100)) {
resultadoX=aux2;
resultadoY=aux1;
}
}

void End()
{
Input.location.Stop();
}


public double transf_Lati_a_U3d(){
return (
(
this.senoAng * (this.puntoGpsLat - this.puntoCeroX) + // Se resta a cada punto la ccordenada 0,0 para centrarlo y rota para ajustarlo utlizando el seno y el coseno
this.cosenoAng * (this.puntoGpsLon - this.puntoCeroY)
)
* this.factorEscala* this.escalaCompX // Se multiplica por la escala general y por la escala para el eje X.
)
- this.getK(); // Se resta un factor de correccion K
}

public double getK(){
return (1 - (-0.1 * Math.Abs(resultadoY)));
}

public double transf_Long_a_U3d(){
return (
this.cosenoAng * (this.puntoGpsLat - this.puntoCeroX) - // Se resta a cada punto la ccordenada 0,0 para centrarlo y rota para ajustarlo utlizando el seno y el coseno
this.senoAng * (this.puntoGpsLon - this.puntoCeroY)
)
* this.factorEscala * this.escalaCompY; // Se multiplica por la escala general y por la escala para el eje X.


}

}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.