You are on page 1of 8

Ipvive Challenge

1. Euclidean geometry
A. Distance formula between two points (x1, y1, z1, w1) and (x2, y2, z2, w2)
According to Euclidean geometry, the square of the distance between a
point A(x1, y2, z1, w1) and a point labeled by B(x2, y2, z2, w2) is given by
2 2 2 2
( x 1x 2) + ( y 1 y 2 ) + ( z 1z 2) + (w 1w 2) and because it is

homogeneous coordinates, so w1, w2 = 1.


Square distance:

dAB 2=dl2 = dx 2 + dy 2 + dz 2 => dl = dl2


B. Distance formula invariant
There are many methods in affine transformation. We can translate the
coordinate system to t:
1 0 0 0
0 1 0 0
[x y 0 0 1 0 z w] = [x y z 1]
tx ty tz 1

Or

x = x + tx

y = y + ty

z = z + tz

w= 1
Under such a relabeling, the distance formula between points A and B is
unchanged.
The distance equation now:

(d l ' )2=( d x ' )2 +(d y ' )2+(d z' )2

Applied to the prime coordinates, gives the same distance. d l' =dl .
Because of this distance invariant under translation of the coordinate
system, it is the invariant.
Proof: (d l ' )2=( d x ' )2 +( d y ' )2+(d z' )2 is the distance of two points after Affine
transformation.
Since both A and B are in Euclidean space. Every affine transformation f:
x -> Mx + b where M is a linear transformation on X and b is a constant.
So dx -> Mdx
And since M is a linear transformation so f(Mdx) = Mf(dx) (homogeneity).
Brief, the distance formula is invariant and preserve under Affine
Transformation.
As long as both points A and B also change the coordinate system. Our
distance formula is invariant.
Proof formula: 2 dimension (similar to 4 dimension)
A (x1, y1), B(x2, y2)
As you can see in the figure below. By the Pythagorean Theorem:

d= ( x2 x1 )2+( y 2 y 1 )2

C. Test demonstration
Case 1: Translation
21

A = (2, 3, 4, 1) B = (1, 2, 3, 1) => = 3

dl=
1 0 0 0
0 1 0 0
[x y z w] = [x y z 1]
0 0 1 0
1 2 3 1

32

A = (3, 5, 7, 1) B= (2, 4, 6, 1) => = 3

d l' =

Brief: The distance before and after translation transformation is the


same and the value also the same since translation transformation is
isometric transformation.
Case 2: Rotation 90 degree

cos -sin 0 0

Rz ( )=
sin cos 0 0

0 0 1 0
0 0 0 1
A = (2, 3, 4, 1) B = (1, 2, 3, 1)
0 0 0
-1
1 0 0 0 A = [2 3 4 1]
0 0 1 0
0 0 0 1
= [3 -2 4 1]
Similar B = [2, -1, 3, 1]
23

= 3

d l' =

Brief: The distance before and after translation transformation is the


same and the value also the same since translation transformation is
isometric transformation.
Scaling, homothety and similarity are examples of affine transformation that
are not an isometry
Code:
#include<iostream>
#include<math.h>
using namespace std;

class dist
{
float x1,x2,y1,y2,z1,z2,w1,w2;
public:
void get()
{
cout<<"\n Enter the value of A(X1,Y1,Z1,W1) and (X2,Y2,Z2,W2):";
cin>>x1>>y1>>z1>>w1>>x2>>y2>>z2>>w2;
}
void calc()

{ float d;
d=sqrt( pow(x1-x2,2) + pow(y1-y2,2) + pow(z1-z2,2) + pow(w1-
w2,2) );

cout<<"\n Distance between point A(X1,Y1,Z1,W1) and (X2,Y2,Z2,W2) is:


"<<d << "\n\n";
}
};

int main()
{

dist m;
m.get();
m.calc();

return 0;
}

2. Spherical geometry.
A. Formula for computing distance

x 2+ y 2 + z 2+ w2=1

We can use Cartesian coordinator


x=r . cos

y=r . sin . cos

z=r . sin . sin . cos

w=r . sin . sin . sin

This is the usual spherical coordinate labeling hyperspherical coordinates on


S3. The distance is given by

dl =r [ d +sin ( d +sin d ) ]
2 2 2 2 2 2 2
or
2 2 2 2 2
dl = dx + dy + dz + dw

So assume that we chose two point on surface of the sphere. Since we use
an orthogonal transformation (a linear transformation), it mean it preserve
the length of vectors.
B. Distance formula invariant
Proof: Similar to the distance in Euclidean geometry. If we convert from
Spherical to Euclidean geometry with Cartesian coordinator.
Since we use orthogonal transformation also a linear transformation and
T a , T b
preserver the inner product. ( a , b ) = ) so the distance formula is invariant

as in Euclidean geometry.
C. Test demonstration
Case 1: Rotate 90 degree
A = A.T (T is orthogonal matrices)
B = B.T

1, 0 Euclidean
A = ( r , , , ) = , ,
2 2 ) (1,0,0,0)


r , , , 1, 0, Euclidean
B=( )= 2 , 2 ) (0,1,0,0)

10

dAB = = 2

dl=

0 0 0
-1 T=
1 0 0 0
0 0 1 0
0 0 0 1
A = A.T = (0, -1, 0 , 0)
B = B.T = (1, 0, 0, 0)
01


2 2 2
dAB = 2+ (10 ) + ( 00 ) + ( 00 )

'
d l =

Brief: The distance is invariant under orthogonal transformation.


Case 2:

1 0 0 0
0 1/ -1/ 0 T=
2 2
0 1/ 1/ 0
2 2
0 0 0 1 A = A.T = (1, 0, 0 , 0)
B = B.T = (0, 1/ 2 , -1/ 2 , 0)
10


2 2 2
dAB = 2+ ( 1/ 20 ) + (1/ 20 ) + ( 00 )

'
d l =

Brief: The distance is invariant under orthogonal transformation.


Code:
3. Hyperbolic geometry.
A. Hyperboloid of one sheet
2 2 2 2
x + y + z w =1

Assume two points A(x1, y2, z1, w1) and B(x2, y2, z2, w2) lie in hyperbolic
above.
The Minkowski bilinear form B
B(a,b) = x1.x2 y1.y2 z1.z2 w1.w2
The hyperbolic distance between two point a and b is given by the formula
d(a,b) = arcosh(B(a,b))
And
Inverse hyperbolic cosin

arcosh(x) = ln( x+ x 1
2

You might also like