<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Infinity Code Forum — Silly math...move a marker at fixed speed towards another marker]]></title>
		<link>https://forum.infinity-code.com/viewtopic.php?id=124</link>
		<atom:link href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=124&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Silly math...move a marker at fixed speed towards another marker.]]></description>
		<lastBuildDate>Thu, 31 Mar 2016 02:35:17 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Silly math...move a marker at fixed speed towards another marker]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=528#p528</link>
			<description><![CDATA[<p>Good to know about lerp.</p><p>I&#039;ve already looked at the examples like I noted above--they don&#039;t document how to set the velocity, which is what I&#039;m trying to figure out <img src="https://forum.infinity-code.com/img/smilies/smile.png" width="15" height="15" alt="smile" /></p><p>I&#039;ll play around with that to see if I can get it figured out, but will probably wind up going with endpoint--I&#039;ve used it before and it does do what I need since it&#039;s what I&#039;m using server side.</p><p>Thanks for the info.</p>]]></description>
			<author><![CDATA[null@example.com (stephen)]]></author>
			<pubDate>Thu, 31 Mar 2016 02:35:17 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=528#p528</guid>
		</item>
		<item>
			<title><![CDATA[Re: Silly math...move a marker at fixed speed towards another marker]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=527#p527</link>
			<description><![CDATA[<p>Hello.</p><p>Lerp will work fine when moving over the equator and the prime meridian, but it fails when the longitude goes from 180 to -180. You need to keep it in mind. </p><p>In the example «MoveMarkerOnRouteExample», shows the smooth movement of the marker along the route.<br /><a href="http://infinity-code.com/atlas/online-maps/pages/MoveMarkerOnRouteExample.html">http://infinity-code.com/atlas/online-m … ample.html</a><br />You can calculate the endpoint in unity, and to adapt the code from the example for your application.</p>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Wed, 30 Mar 2016 22:37:48 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=527#p527</guid>
		</item>
		<item>
			<title><![CDATA[Silly math...move a marker at fixed speed towards another marker]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=526#p526</link>
			<description><![CDATA[<p>20 years ago this would have been trivial for me, but I can&#039;t wrap my head around what I think is a pretty easy scenario:</p><p>I have two types of markers: city markers, and hireling markers. Hireling markers can move (from city to city, or to other locations), and their position is controlled directly by the server, with periodic updates sent down to the client.</p><p>This means that every time an update comes down from the server, the hireling marker &quot;leaps&quot; to the new position (long/lat coords).</p><p>On the client, I would like to give the hireling marker a small velocity towards the city marker it is moving to, so that I don&#039;t have to send so many updates yet still have the marker move more smoothly.</p><p>Obviously, markers don&#039;t have underlying physics, so I&#039;m more than willing to use observe() to update the marker&#039;s position every few seconds to simulate smooth movement...but that&#039;s where I&#039;m stuck.</p><p>The examples (animating a marker, smooth move of the camera to a marker) all use lerp, but unfortunately don&#039;t seem to indicate how to control the velocity of the marker directly with a rate (for example, 5 km/hour). Additionally, I strongly suspect that lerp will fail across lat/lng sign changes (equator, prime meridian), sending my marker off into semi-random space.</p><p>On my server, my geocoder implementation has a utility called endpoint, which does the following (the language is Ruby, but should be relatively easy to understand):</p><div class="codebox"><pre><code>    # Given a start point, heading (in degrees), and distance, provides
    # an endpoint.

def endpoint(start, heading, distance, options = {})
      options[:units] ||= Geocoder.config.units
      radius = earth_radius(options[:units])

      start = extract_coordinates(start)

      # convert degrees to radians
      start = to_radians(start)

      lat = start[0]
      lon = start[1]
      heading = to_radians(heading)
      distance = distance.to_f

      end_lat = Math.asin(Math.sin(lat)*Math.cos(distance/radius) +
                    Math.cos(lat)*Math.sin(distance/radius)*Math.cos(heading))

      end_lon = lon+Math.atan2(Math.sin(heading)*Math.sin(distance/radius)*Math.cos(lat),
                    Math.cos(distance/radius)-Math.sin(lat)*Math.sin(end_lat))

      to_degrees [end_lat, end_lon]
    end</code></pre></div><p>Is there anything similar in OnlineMaps? I&#039;ve searched through the OnlineMapsUtils.cs and some of the pieces seem to be there, but I can&#039;t quite figure out how to get it working together.</p><p>Any ideas or suggestions?</p><p>Thanks in advance...</p>]]></description>
			<author><![CDATA[null@example.com (stephen)]]></author>
			<pubDate>Wed, 30 Mar 2016 22:10:45 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=526#p526</guid>
		</item>
	</channel>
</rss>
