Posts

Showing posts with the label 2D vector

mathajax

Vector Dot Product

Image
The Java code finds the dot product of two vectors v1 and v2 .   it is also called as scalar product or inner product and  defined as sum of  product of  respective axis element of  the two vectors . Their vector's element can be integer or double of java datatype. Dot product of 2-D vectors Dot product of N-D vectors Dot product of 2D vectors A class Vector defined two member functions named " dot-product " with parameter type difference, in order to support  parameters  int or double type 2D vectors.  . Both member function can be invoked with two array parameters, which represents the vectors to be dot-product. These vectors must have 2 elements. for example  below shows how to calculate dot product two vectors A and B using above equation Vector A = [1 5] Vector B = [2 3] A.B = 1x2 + 5x3 = 2 + 15 A.B = 17     import jav...

Vector - magnitude

Image
The java code finds magnitude of a vector which can be 2 Dimension or 3 Dimension or any number of dimension. A java class Vector defined with two member functions to calculate magnitude of a vector in double or integer datatype. As the both member function declared with keyword static,  we can access the member function by class class name.  we do not need to create object to the class. Magnitude of 2D vector Equation Magnitude of N-Dimensional vector Equation Example Calculation This is an example calculation shown below that explains how to find a vector magnitude . A vector,array of elements declared and initialized in java using one dimensional array. int A[] = { 2 ,3 }; // 2D vector A find a magnitude for vector A |A| = sqrt ( A[0]^2 + A[1]^2 ) = sqrt ( 2^2 + 3^2 ); = sqrt ( 4 + 9 ); = sqrt ( 13 ); |A| = 3.605 m...

Distance Metric - Euclidean Distance

Image
The java program finds distance between two points by Euclidean distance metric and the points can be a scalar (single element) or a vector (more than one element). The Euclidean distance between two points is measured based on Pythagoras theorem on right angle triangle. AC 2 = AB 2 + BC 2 AC 2 - area of hypotenous AB 2 – area of base BC 2 – area of perpendicular Euclidean distance= AC = sqrt( AB ^2 +BC ^2 ) Euclidean distance - on 1-D The points x and y are scalar on 1-dimension and each point has one element. It is consider that the points on a measuring scale in case of 1-Dimension. The distance between these two points are measured by the following formula. ID-Euclidean  Euclidean distance - on 2-D The points x and y are vector on 2-dimension and each point has two elements.It is consider that the points on a Cartesian 2-D coordinate graph in case of ...