Class VectorExtensions
Inheritance
Inherited Members
Namespace:Mapbox.Unity.Utilities
Assembly:cs.temp.dll.dll
Syntax
public static class VectorExtensions
Methods
AsUnityPosition(Vector2, Vector2d, Single)
Vector2 extension method to convert from a latitude/longitude to a Unity Vector3.
Declaration
public static Vector3 AsUnityPosition(this Vector2 latLon, Vector2d refPoint, float scale = 1F)
Parameters
Type | Name | Description |
---|---|---|
Vector2 | latLon | Latitude Longitude. |
Vector2d | refPoint | Reference point. |
System.Single | scale | Scale. |
Returns
Type | Description |
---|---|
Vector3 | The Vector3 Unity position. |
GetGeoPosition(Transform, Vector2d, Single)
Transform extension method to return the transform's position as a Vector2d latitude/longitude.
Declaration
public static Vector2d GetGeoPosition(this Transform t, Vector2d refPoint, float scale = 1F)
Parameters
Type | Name | Description |
---|---|---|
Transform | t | T. |
Vector2d | refPoint | Reference point. |
System.Single | scale | Scale. |
Returns
Type | Description |
---|---|
Vector2d | Vector2d that represents latitude/longitude. |
Examples
Get the latitude/longitude of a transform at (1113195, 0, 1118890), map center (0, 0) and scale 1.
var latLng = transform.GetGeoPosition(new Vector2d(0, 0), 1);
Debug.Log(latLng);
// (10.00000, 10.00000)
GetGeoPosition(Vector2, Vector2d, Single)
Declaration
public static Vector2d GetGeoPosition(this Vector2 position, Vector2d refPoint, float scale = 1F)
Parameters
Type | Name | Description |
---|---|---|
Vector2 | position | |
Vector2d | refPoint | |
System.Single | scale |
Returns
Type | Description |
---|---|
Vector2d |
GetGeoPosition(Vector3, Vector2d, Single)
Declaration
public static Vector2d GetGeoPosition(this Vector3 position, Vector2d refPoint, float scale = 1F)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | position | |
Vector2d | refPoint | |
System.Single | scale |
Returns
Type | Description |
---|---|
Vector2d |
MoveToGeocoordinate(Transform, Double, Double, Vector2d, Single)
Transform extension method to move a Unity transform to a specific latitude/longitude.
Declaration
public static void MoveToGeocoordinate(this Transform t, double lat, double lng, Vector2d refPoint, float scale = 1F)
Parameters
Type | Name | Description |
---|---|---|
Transform | t | Transform. |
System.Double | lat | Latitude. |
System.Double | lng | Longitude. |
Vector2d | refPoint | Reference point. |
System.Single | scale | Scale. |
Examples
Place a Unity transform at 10, 10, with a map center of (0, 0) and scale 1:
transform.MoveToGeocoordinate(10, 10, new Vector2d(0, 0), 1f);
Debug.Log(transform.position);
// (1113195.0, 0.0, 1118890.0)
MoveToGeocoordinate(Transform, Vector2d, Vector2d, Single)
Transform extension method to move a Unity transform to a specific Vector2d.
Declaration
public static void MoveToGeocoordinate(this Transform t, Vector2d latLon, Vector2d refPoint, float scale = 1F)
Parameters
Type | Name | Description |
---|---|---|
Transform | t | Transform. |
Vector2d | latLon | Latitude Longitude. |
Vector2d | refPoint | Reference point. |
System.Single | scale | Scale. |
Examples
Place a Unity transform at 10, 10, with a map center of (0, 0) and scale 1:
transform.MoveToGeocoordinate(new Vector2d(10, 10), new Vector2d(0, 0), 1f);
Debug.Log(transform.position);
// (1113195.0, 0.0, 1118890.0)
Perpendicular(Vector3)
Declaration
public static Vector3 Perpendicular(this Vector3 v)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | v |
Returns
Type | Description |
---|---|
Vector3 |
ToVector2d(Vector3)
Vector3 convenience method to convert Vector3 to Vector2d.
Declaration
public static Vector2d ToVector2d(this Vector3 v)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | v | Vector3. |
Returns
Type | Description |
---|---|
Vector2d | The Vector2d. |
ToVector2xz(Vector3)
Vector3 convenience method to convert Vector3 to Vector2.
Declaration
public static Vector2 ToVector2xz(this Vector3 v)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | v | Vector3. |
Returns
Type | Description |
---|---|
Vector2 | The Vector2. |
ToVector3xz(Vector2)
Vector2 convenience method to convert Vector2 to Vector3.
Declaration
public static Vector3 ToVector3xz(this Vector2 v)
Parameters
Type | Name | Description |
---|---|---|
Vector2 | v | Vector2. |
Returns
Type | Description |
---|---|
Vector3 | Vector3 with a y value of zero. |
ToVector3xz(Vector2d)
Vector2d convenience method to convert Vector2d to Vector3.
Declaration
public static Vector3 ToVector3xz(this Vector2d v)
Parameters
Type | Name | Description |
---|---|---|
Vector2d | v | Vector2d. |
Returns
Type | Description |
---|---|
Vector3 | Vector3 with a y value of zero. |