Namespaces
Variants
Actions
Revision as of 20:36, 12 January 2012 by avnee.nathani (Talk | contribs)

HERE Maps API - Utility class Vector3D

Jump to: navigation, search
MultiMediaTile.png
Article Metadata

Tested with
Devices(s): Opera 5.0.5, Firefox 5.0
Dependencies: Nokia Maps 2.1.0

Article
Created: Maveric (28 Jun 2011)
Last edited: avnee.nathani (12 Jan 2012)


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://api.maps.nokia.com/2.1.0/apireference/symbols/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 a 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 angle for the 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 shall be 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

  • Opera 5.0.5
  • Firefox 5.0
369 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved