×
Namespaces

Variants
Actions
(Difference between revisions)

HERE Maps API - Utility class Vector3D

From Nokia Developer Wiki
Jump to: navigation, search
hamishwillee (Talk | contribs)
m (Hamishwillee - Automated change of category from Ovi Maps to Nokia Maps)
jasfox (Talk | contribs)
m (Jasfox - version)
(8 intermediate revisions by 5 users not shown)
Line 1: Line 1:
[[Category:Web]][[Category:Browser]][[Category:Nokia Maps]]
+
[[Category:Nokia Maps]][[Category:Code Snippet]][[Category:JavaScript]]
 +
{{ArticleMetaData
 +
|sourcecode= <!-- Link to example source code e.g. [[Media:The Code Example ZIP.zip]] -->
 +
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
 +
|devices= Firefox 12.0
 +
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
 +
|platform= <!-- Compatible platforms - e.g. Symbian^1 and later, Qt 4.6 and later -->
 +
|devicecompatability= <!-- Compatible devices e.g.: All* (must have internal GPS) -->
 +
|dependencies=Nokia Maps 2.2.3
 +
|signing=<!-- Signing requirements - empty or one of: Self-Signed, DevCert, Manufacturer -->
 +
|capabilities= <!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. -->
 +
|keywords= Nokia Maps, JavaScript, vectors
 +
|id= <!-- Article Id (Knowledge base articles only) -->
 +
|language= <!-- Language category code for non-English topics - e.g. Lang-Chinese -->
 +
|translated-by= <!-- [[User:XXXX]] -->
 +
|translated-from-title= <!-- Title only -->
 +
|translated-from-id= <!-- Id of translated revision -->
 +
|review-by=<!-- After re-review: [[User:username]] -->
 +
|review-timestamp= <!-- After re-review: YYYYMMDD -->
 +
|update-by= <!-- After significant update: [[User:username]]-->
 +
|update-timestamp= <!-- After significant update: YYYYMMDD -->
 +
|creationdate=20110628
 +
|author=[[User:Maveric]]
 +
}}
 +
{{SeeAlso|
 +
*  [http://developer.here.net/javascript_api Nokia Maps API]
 +
}}
 +
 
 
{{Abstract|This article explains how to use the Vector3D utility class.}}  
 
{{Abstract|This article explains how to use the Vector3D utility class.}}  
  
Line 6: Line 33:
 
This is a class representing a three dimensional vector. Full description is here:
 
This is a class representing a three dimensional vector. Full description is here:
  
http://api.maps.ovi.com/apireference/symbols/ovi.mapsapi.util.Vector3D.html
+
http://developer.here.net/docs/maps_js/topics_api_pub/nokia.maps.util.Vector3D.html
  
 
== Usage examples ==
 
== Usage examples ==
Line 13: Line 40:
  
 
<code java>
 
<code java>
>>> myVector = new ovi.mapsapi.util.Vector3D (10, 10, 10) ;
+
>>> myVector = new nokia.maps.util.Vector3D (10, 10, 10) ;
 
</code>
 
</code>
  
Line 22: Line 49:
  
  
The "add(other)" method would create a sum of this vector and the added one.
+
The "add(other)" method would create the sum of this vector and the added one.
 
   
 
   
 
We will create two Vector3D's and then create the third based on adding the 2nd to the 1st Vector3D.
 
We will create two Vector3D's and then create the third based on adding the 2nd to the 1st Vector3D.
  
 
<code java>
 
<code java>
>> myVector1 = new ovi.mapsapi.util.Vector3D (10, 10, 10) ;
+
>> myVector1 = new nokia.maps.util.Vector3D (10, 10, 10) ;
>> myVector2 = new ovi.mapsapi.util.Vector3D (20, 20, 20) ;
+
>> myVector2 = new nokia.maps.util.Vector3D (20, 20, 20) ;
 
>> myVector3 = myVector1.add(myVector2);
 
>> myVector3 = myVector1.add(myVector2);
 
</code>
 
</code>
Line 41: Line 68:
 
angle ([px, [py, [intertX, [intertY]]]]) : Number
 
angle ([px, [py, [intertX, [intertY]]]]) : Number
 
   
 
   
Example on requesting angle for the myVector3:
+
Example on requesting the angle for myVector3:
 
   
 
   
<code java>
+
<code javascript>
 
>>> myVector3.angle();
 
>>> myVector3.angle();
 
</code>
 
</code>
  
 
Would return us a numeric value as follows:
 
Would return us a numeric value as follows:
<code java>
+
<code javascript>
 
45.00000000000001
 
45.00000000000001
 
</code>
 
</code>
Line 54: Line 81:
 
And let's try one more operation with the "subtract" method. With it we can get the difference between two vectors:
 
And let's try one more operation with the "subtract" method. With it we can get the difference between two vectors:
  
<code java>
+
<code javascript>
 
>>> subtracted = myVector3.subtract(myVector1);
 
>>> subtracted = myVector3.subtract(myVector1);
 
</code>
 
</code>
  
 
Would return us:
 
Would return us:
<code java>
+
<code javascript>
 
Object { x=20, y=20, z=20}
 
Object { x=20, y=20, z=20}
 
</code>
 
</code>
Line 71: Line 98:
 
coordinate system that goes possitive to top/right.
 
coordinate system that goes possitive to top/right.
  
For screen coordinates the Y-axis shall be inverted. For a normalized vector  
+
For screen coordinates the Y-axis is inverted. For a normalized vector  
 
the method can be called without parameters to return it's normalized angle.
 
the method can be called without parameters to return it's normalized angle.
  
 
Parameters:
 
Parameters:
{Number}     [px]:     The x-coordinate of the point to which the angle shall be calculated, if not given zero is used.
+
{Number}     [px]:       The x-coordinate of the point to which the angle shall be calculated, if not given zero is used.
{Number}     [py]:     The y-coordinate of the point to which the angle shall be calculated, if not given zero is used.
+
{Number}     [py]:       The y-coordinate of the point to which the angle shall be calculated, if not given zero is used.
{Boolean}    [intertX]:     If given and true, the x-axis is inverted, therefore the coordinates are increasing to the left and decreasing to the right.
+
{Boolean}    [intertX]:   If given and true, the x-axis is inverted, therefore the coordinates are increasing to the left and decreasing to the right.
{Boolean}    [intertY]:     If given and true, the y-axis is inverted, therefore the coordinates are increasing to the bottom and decreasing to the top.
+
{Boolean}    [intertY]:   If given and true, the y-axis is inverted, therefore the coordinates are increasing to the bottom and decreasing to the top.
 +
 
 
Returns:
 
Returns:
 
{Number}    The angle of this vector in degree, relative to the given coordinate.  
 
{Number}    The angle of this vector in degree, relative to the given coordinate.  
Line 85: Line 113:
 
== Tested with ==
 
== Tested with ==
  
Windows XP Professional
+
* Firefox 12.x
 
+
Opera 5.0.5
+
 
+
Firefox 5.0
+

Revision as of 16:07, 3 January 2013

Article Metadata
Tested with
Devices(s): Firefox 12.0
Dependencies: Nokia Maps 2.2.3
Article
Keywords: Nokia Maps, JavaScript, vectors
Created: Maveric (28 Jun 2011)
Last edited: jasfox (03 Jan 2013)
See Also

This article explains how to use the Vector3D utility class.

Introduction

This is a class representing a three dimensional vector. Full description is here:

http://developer.here.net/docs/maps_js/topics_api_pub/nokia.maps.util.Vector3D.html

Usage examples

Let's create a new Vector3D object:

>>> myVector = new nokia.maps.util.Vector3D (10, 10, 10) ;

This would return and object containing:

Object { x=10, y=10, z=10}


The "add(other)" method would create the sum of this vector and the added one.

We will create two Vector3D's and then create the third based on adding the 2nd to the 1st Vector3D.

>> myVector1 = new nokia.maps.util.Vector3D (10, 10, 10) ;
>> myVector2 = new nokia.maps.util.Vector3D (20, 20, 20) ;
>> myVector3 = myVector1.add(myVector2);

We would now have myVector3 to contain:

Object { x=30, y=30, z=30 }

With the method "angle" we can request, as the name says the relative angle: angle ([px, [py, [intertX, [intertY]]]]) : Number

Example on requesting the angle for myVector3:

>>> myVector3.angle();

Would return us a numeric value as follows:

45.00000000000001

And let's try one more operation with the "subtract" method. With it we can get the difference between two vectors:

>>> subtracted = myVector3.subtract(myVector1);

Would return us:

Object { x=20, y=20, z=20}

Feel free to try the other methods too, used in a similar manner.

Description of the angle method:

angle ([px, [py, [intertX, [intertY]]]]) : Number
Returns the angle of this vector in decimal degree to the given point within a
coordinate system that goes possitive to top/right.
 
For screen coordinates the Y-axis is inverted. For a normalized vector
the method can be called without parameters to return it's normalized angle.
 
Parameters:
{Number} [px]: The x-coordinate of the point to which the angle shall be calculated, if not given zero is used.
{Number} [py]: The y-coordinate of the point to which the angle shall be calculated, if not given zero is used.
{Boolean} [intertX]: If given and true, the x-axis is inverted, therefore the coordinates are increasing to the left and decreasing to the right.
{Boolean} [intertY]: If given and true, the y-axis is inverted, therefore the coordinates are increasing to the bottom and decreasing to the top.
 
Returns:
{Number} The angle of this vector in degree, relative to the given coordinate.

Tested with

  • Firefox 12.x
148 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×