How to make a bissetriz line?

Status
Not open for further replies.

Crigui

Usenet Archive
Joined
Sep 28, 2001
Messages
39
Reaction score
0
Hi,

We've asked all of you before about how to get the angle between two lines. We tryed to use all of them but we forgot to tell you about what we were thinking about doing with that: we were trying to construct a bissetriz, I mean, get the angle that two line make and divide by 2, finding the bissetriz. The values that we got using atan2 were very strange and we weren't knowing how to manipulate them... So that's why we are trying to find some specific help...

Thanks for continue helping us...

Crigui.
 
This may seem very ugly, but it was used to calulate the angle between adjacent building walls. points[0] is an angle leg, points[1] is the vertex, points[2] is the other angle leg. Once you have the angle, you can transform elements around any point.

/*----------------------------------------------------------------------+ | name form_getCornerAngle +----------------------------------------------------------------------*/ Private double form_getCornerAngle (void) { double zRotation1, zRotation2, angle, rads; double dx = points[0].x - points[1].x; double dy = points[0].y - points[1].y;

// Wall1 orientataion
if (dx != 0)
rads = atan(dy / dx);
if (rads < 0)
rads *= -1;
// east
if ((dy == 0) && (dx > 0))
zRotation1 = 0;
// north
else if ((dx == 0) && (dy > 0))
zRotation1 = fc_piover2;
// west
else if ((dy == 0) && (dx < 0))
zRotation1 = fc_pi;
// south
else if ((dx == 0) && (dy < 0))
zRotation1 = fc_pi + fc_piover2;
// northeast
else if ((dx > 0) && (dy > 0))
zRotation1 = rads;
// northwest
else if ((dx < 0) && (dy > 0))
zRotation1 = fc_pi - rads;
// southwest
else if ((dx < 0) && (dy < 0))
zRotation1 = fc_pi + rads;
// southeast
else if ((dx > 0) && (dy < 0))
zRotation1 = fc_2pi - rads;

// Wall2 orientataion
dx = points[2].x - points[1].x;
dy = points[2].y - points[1].y;
if (dx != 0)
rads = atan(dy / dx);
if (rads < 0)
rads *= -1;
// east
if ((dy == 0) && (dx > 0))
zRotation2 = 0;
// north
else if ((dx == 0) && (dy > 0))
zRotation2 = fc_piover2;
// west
else if ((dy == 0) && (dx < 0))
zRotation2 = fc_pi;
// south
else if ((dx == 0) && (dy < 0))
zRotation2 = fc_pi + fc_piover2;
// northeast
else if ((dx > 0) && (dy > 0))
zRotation2 = rads;
// northwest
else if ((dx < 0) && (dy > 0))
zRotation2 = fc_pi - rads;
// southwest
else if ((dx < 0) && (dy < 0))
zRotation2 = fc_pi + rads;
// southeast
else if ((dx > 0) && (dy < 0))
zRotation2 = fc_2pi - rads;

// return angle in degrees
angle = (zRotation2 - zRotation1) * 180 / fc_pi;
if (angle < 0)
angle += 360;

return (angle);
}
 
Hello

The program example can be simplefied by using atan2 instead of atan this function does does deliver a angle between -fc_pi and fc_pi (-180
- 180 degrees).

The arguments are dx and dy from atan(dy/dx).

Greetins Olaf Giezenaar

/*----------------------------------------------------------------------+ | name form_getCornerAngle +----------------------------------------------------------------------*/ Private double form_getCornerAngle (void) { double zRotation1, zRotation2, angle; double dx = points[0].x - points[1].x; double dy = points[0].y - points[1].y;

// Wall1 orientataion
zRotation1 = atan2(dy , dx);

// Wall2 orientataion
dx = points[2].x - points[1].x;
dy = points[2].y - points[1].y;
zRotation2 = atan2(dy , dx);

// return angle in degrees
angle = (zRotation2 - zRotation1) * fc_180overpi;
while (angle < fc_zero)
angle += fc_360;

return (angle);
}
 
Status
Not open for further replies.

Latest threads

Back
Top