<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Infinity Code Forum — Losing precision]]></title>
	<link rel="self" href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=1593&amp;type=atom" />
	<updated>2020-08-28T18:35:27Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.infinity-code.com/viewtopic.php?id=1593</id>
		<entry>
			<title type="html"><![CDATA[Re: Losing precision]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=6633#p6633" />
			<content type="html"><![CDATA[<p>Thanks I will continue to trace through and see where it might be happening</p>]]></content>
			<author>
				<name><![CDATA[mcb]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=1341</uri>
			</author>
			<updated>2020-08-28T18:35:27Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=6633#p6633</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Losing precision]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=6632#p6632" />
			<content type="html"><![CDATA[<p>Loss of precision from double to float conversion, up to 1 meter.<br />In your screenshot in post 1, I see a distance of about 100 meters (visually) and this is definitely not a loss of precision.</p><p>Somewhere you have a bug, but where it is difficult to say.<br />The code you showed looks good and does not contain a bug that could cause this behavior.<br />Try to track the coordinates of the marker in all phases, when you interact with it (create under the cursor, save, load).<br />There is a bug somewhere, and it might be a typo.</p><p>If you can&#039;t find the problem, in theory we can schedule a call using AnyDesk next week. I will connect to you and check on your side why this is happening.</p>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2020-08-28T18:24:49Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=6632#p6632</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Losing precision]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=6629#p6629" />
			<content type="html"><![CDATA[<p>they are doubles.</p><p>Database shows:<br />lat =&nbsp; 33.4089173493387<br />long = -105.44465691910773</p><p>Loaded:<br />lat = 33.4089173493387 <br />long = -105.444656919108</p><p>pixels are 1024x1024</p><p>Is it possible this is hitting some kind of Unity limit?&nbsp; </p><p>The lat has 13 decimals stored and the long has 14, but when loaded, I&#039;m losing 2 whole decimals on the long due to rounding. I&#039;m certainly not rounding the long.</p>]]></content>
			<author>
				<name><![CDATA[mcb]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=1341</uri>
			</author>
			<updated>2020-08-28T13:04:33Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=6629#p6629</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Losing precision]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=6628#p6628" />
			<content type="html"><![CDATA[<p>What type are actorLatitude and actorLongitude?<br />Do you have the same values when serializing and deserializing?<br />What values do you have in Map / Width and Height (pixels)?</p>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2020-08-27T20:45:17Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=6628#p6628</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Losing precision]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=6627#p6627" />
			<content type="html"><![CDATA[<p>This is how I create the 3d marker<br /></p><div class="codebox"><pre><code>if (Input.GetMouseButtonDown(0))
{
    double lng, lat;
    OnlineMapsControlBase3D.instance.GetCoords(out lng, out lat);
    // Create 3D marker
    OnlineMapsMarker3D marker3D = OnlineMapsMarker3DManager.CreateItem(lng, lat, currentPlaceableObject);
    // push the data out to be saved
    SetPosition(lat, lng);
}</code></pre></div><p>Here is SetPosition, called when the user places the model, in a separate script.</p><div class="codebox"><pre><code>public void SetPosition(double lat, double lng)
    {
        this.actorLatitude = lat;
        this.actorLongitude = lng;
}</code></pre></div><p>I then serialize that data and push it to my DB.&nbsp; </p><p>And this is how I load it:</p><div class="codebox"><pre><code>private void LoadMission(SceneActor actor){
    // Create 3D marker
    OnlineMapsMarker3D marker3D = OnlineMapsMarker3DManager.CreateItem(actor.actorLongitude, actor.actorLatitude, actor);
    
}</code></pre></div><br /><p>Note, I was able to keep making progress and skirt this issue by just storing the Transform values and instantiating a game object instead of using the 3d marker.</p>]]></content>
			<author>
				<name><![CDATA[mcb]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=1341</uri>
			</author>
			<updated>2020-08-27T20:31:12Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=6627#p6627</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Losing precision]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=6624#p6624" />
			<content type="html"><![CDATA[<p>Hello.</p><p>I see in your screenshot the distance between markers is 100+ meters, which is a lot and cannot happen simply due to the loss of precision between float and double.<br />I think you have a problem with saving / loading coordinates.<br />Please attach the code that saves the coordinates and the code that loads the coordinates.<br />I will check it.</p>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2020-08-27T18:54:21Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=6624#p6624</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Losing precision]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=6623#p6623" />
			<content type="html"><![CDATA[<p>Hey Devs,<br />So I&#039;m having an issue with precision that you might be able to help with.</p><p>I&#039;m trying to place 3d markers as in the examples...</p><div class="codebox"><pre><code>double lng, lat;
OnlineMapsControlBase3D.instance.GetCoords(out lng, out lat);
// Create 3D marker
OnlineMapsMarker3D marker3D = OnlineMapsMarker3DManager.CreateItem(lng, lat, currentPlaceableObject);</code></pre></div><p>I then save the lat/lng to my database, but when I load the 3dmarker using the same data, it&#039;s not in the same spot.</p><p>Attached is a screenshot of my initial placement, showing the model placed by the mouse, and the 3d marker placed by the lat/long recieveded from mouse clicking the map.</p><p>As you can see, there is a small, but significant difference between the 2.</p><p>I&#039;m currently going to simply store the Cartesian coords of the model placed on mouse click, and use that to place the 3d marker ( I hope)</p><p>But maybe there is something simple I&#039;m missing?</p><p>Here is how I create the 3d marker on load</p><div class="codebox"><pre><code>// Create 3D marker
OnlineMapsMarker3D marker3D = OnlineMapsMarker3DManager.CreateItem(actor.actorLongitude, actor.actorLatitude, actor);</code></pre></div><p>and just the sake of data precision, here is what I&#039;m storing for the lat/lng</p><p>lat -17.0355420413186 <br />lng -53.7589743348561</p>]]></content>
			<author>
				<name><![CDATA[mcb]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=1341</uri>
			</author>
			<updated>2020-08-27T13:37:06Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=6623#p6623</id>
		</entry>
</feed>
