Monday 18 January 2016

Mid Point Ellipse Algorithm

 Mid Point Ellipse Algorithm

Lets start with the general definition of Ellipse that is:

"the set of all points, the sum of whose distances from two fixed points is a constant.

In Mathematical term,


d1 + d2 = constant

For an ellipse with center point (h,k), the standard rectangular expression can be written as

{ (x-h)/a }2 + { (y-k)/b }2 = 1

So, lets assume a ellipse with center at origin ((h,k)= (0,0)), having major and minor axis a and b respectively,
By putting all this value in above equation, we get

(x/a)2 + (y/b)2 = 1

On solving:

 (x/a)2 + (y/b)2 - 1 = 0

In first region, the equation will be:
  
f(x, y) = a2x2 + b2y2 - a2b2


The mid points will be
F(Xmid, Ymid) = (Xk+1 , Yk – 1/2)

having following properties:    
  1. F(Xmid, Ymid) < 0, when midpoints will lie inside the ellipse boundary.
  2. F(Xmid, Ymid) = 0, when midpoints will lie on ellipse boundary.
  3. F(Xmid, Ymid) > 0, when midpoints will lie outside the ellipse boundary. 
Now, put this midpoints value in first region equation:
F(Xmid , Ymid) = b2(Xk+1)2 + a2(Yk - 1/2)2 – a2b2

On solving:
P’k = b2(Xk+1)2 + a2(Yk2 + ¼ - Yk) – a2b2
P’k = b2(Xk2 + 1 + 2Xk) + a2(Yk2 + ¼ -Yk) – a2b2

and
P’k+1 = b2(Xk+12 + 1 + 2Xk+1) + a2(Yk+12 + ¼ -Yk+1) – a2b2

Initial decision parameter of Region-1 is (0 , b), hence putting this value in above equation:
P’o=b2(0+1+0) + a2(b2 + ¼ -b) – a2b2
P’o = b2 + a2b2 + a2/4 –a2b – a2b2
P’o= b2 + a2/4 – a2b
P’o= a2/4 – a2b + b2

This is the initial decision parameter of region 1.

Now, substracting P'k from P'k+1
P’k+1 – P’k = b2(Xk+12 – X2k) +2b2(Xk+1-Xk) + a2(Yk+12 – Yk2) + a2(Yk+1 - Yk)
P’k+1 – P’k = b2(Xk+1 – Xk)(Xk+1 + Xk) +2b2(Xk+1-Xk) + a2(Yk+1 – Yk)(Yk+1 + Yk) -a2(Yk+1 - Yk)

If P is negative: 
Xk+1 – Xk = 1
Yk+1 – Yk = 0

hence
P’k+1 = P’k + 2b2 Xk+1 + b2

This is the decision parameter for less than zero of region 1.

If P is positive: 
Xk+1 – Xk = 1
Yk+1 – Yk = -1

hence
P’k+1 = P’k +b2(Xk+1 + Xk) + 2b2 + a2(-1)(Yk+1 + Yk) –a2(-1)
P’k+1 = P’k + 2b2 Xk+1 + b2 – 2a2 Yk+1

This is the decision parameter for greater than zero of region 1

Over Region R2
Now lets solve the derivation for region 2

F(X,Y) = b2X2 + a2Y2 – a2b2

F(Xmid , Ymid) = (Xk+1/2 , Yk – 1)
F(Xmid , Ymid) = b2(Xk + 1/2)2 + a2(Yk - 1)2 – a2b2

hence
P’’k = b2(Xk + 1/2)2 + a2(Yk - 1)2 – a2b2
P’’k = b2(X2k + 1/4 + Xk) + a2(Y2k + 1 -2Yk) – a2b2
P’’k+1 = b2(Xk+12 + 1/4 + Xk+1) + a2(Yk+12 + 1 -2Yk+1) – a2b2

Initial decision parameter of Region R2 (X0 , Y0):
 P’’0 = b2(x0 + 1/2)2 + a2( Y0 - 1)2 – a2b2

This is the initial decision parameter of region R2.

Now, substracting P'k from P'k+1:
P’k+1 – P’k = b2(X2k+1 – Xk2) +b2(Xk+1 - Xk) + a2(Yk+12 – Y2k) -2a2(Yk+1 - Yk)
P’k+1 – P’k = b2(Xk+1 – Xk)(Xk+1 + Xk) +b2(Xk+1-Xk) + a2(Yk+1 – Yk)(Yk+1 + Yk) -2a2(Yk+1 - Yk)

If P is positive: 
Xk+1 – Xk = 0
Yk+1 – Yk = -1

Hence
P’’k+1 = P’’k – 2a2 Yk+1 + a2

This is the decision parameter for greater than zero of region 2.

If P is negative:
Xk+1 – Xk = 1
Yk+1 – Yk = -1

Hence
P’’k+1 = P’’k + 2b2 Xk+1 -2a2 Yk+1 + a2

This is the decision parameter for less than zero of region 2.


X2/a2 + Y2/b2 – 1 = 0 b2X2 + a2Y2 – a2b2

Copy the BEST Traders and Make Money : http://bit.ly/fxzulu
Assume that a ellipse with center at origin with major and minor axis a and b. Than the equation of ellipse will be

Copy the BEST Traders and Make Money : http://bit.ly/fxzulu
that a ellipse with center at origin with major and minor axis a and b. Than the equation of ellipse will be

Copy the BEST Traders and Make Money : http://bit.ly/fxzulu
that a ellipse with center at origin with major and minor axis a and b. Than the equation of ellipse will be

Copy the BEST Traders and Make Money : http://bit.ly/fxzulu
that a ellipse with center at origin with major and minor axis a and b. Than the equation of ellipse will be

Copy the BEST Traders and Make Money : http://bit.ly/fxzulu
that a ellipse with center at origin with major and minor axis a and b. Than the equation of ellipse will be

Copy the BEST Traders and Make Money : http://bit.ly/fxzuludhjkdkcbmnxbnzcbnxnzbnmz
that a ellipse with center at origin with major and minor axis a and b. Than the equation of ellipse will be

Copy the BEST Traders and Make Money : http://bit.ly/fxzulu
that a ellipse with center at origin with major and minor axis a and b. Than the equation of ellipse will be

Copy the BEST Traders and Make Money : http://bit.ly/fxzulu
that a ellipse with center at origin with major and minor axis a and b. Than the equation of ellipse will be

Copy the BEST Traders and Make Money : http://bit.ly/fxzulu
that a ellipse with center at origin with major and minor axis a and b. Than the equation of ellipse will be

Copy the BEST Traders and Make Money : http://bit.ly/fxzulu

1 comments:

 

Copyright @ 2013 Appychip.

Designed by Appychip & YouTube Channel