problem 190
Posted: Tue May 28, 2002 7:50 am
Can you tell me, how can I find the center from three points?
Code: Select all
The midpoint's coordinates of section AB:
A + B A + B
x x y y
P (--------- ; ---------) (1)
mid 2 2
The direction vector of section AB:
v (B - A ; B - A ) (2)
x x y y
The normalvector of a direction vector v (v ; v ):
1 2
n (-v ; v ) (3)
2 1
Line's equatoin passing through point
P (x ; y ) direction v (v ; v ) is:
0 0 1 2
v X - v Y = v x - v y (4)
2 1 2 0 1 0
That's all.
The calculation:
Section AB's direction vector is from (2):
v (B - A ; B - A ) (5)
x x y y
Section AB's normal vector is from (5) and (3):
v (A - B ; B - A ) (6)
y y x x
The equation of bisector of section AB is
from (4) and (5) and (6) and (1):
A + B A + B
x x y y
(B - A )X + (B - A )Y = (B - A )------- + (B - A )------- (7)
x x y y x x 2 y y 2
It's equal to:
2 2 2 2
2 (B - A ) X + 2 (B - A ) Y = B - A + B - A (8)
x x y y x x y y
The equation of bisector of section AC is in the same way:
2 2 2 2
2 (C - A ) X + 2 (C - A ) Y = C - A + C - A (9)
x x y y x x y y
Can you give me some examples with C/C++ code ???if some expression results float number 0, you may got -0.00000000001 for example, then if you cast it to integer, you may got -0, not 0!!
Code: Select all
can anyone help me? thanx
BTW i use cc to compile at home, and it's OK