Problems trying to get the bissetriz...

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 did it using the intersection and end-start points of the lines.

The specific way that you've given to us has some mistakes, for example, when a same angle changes its place on the screen, it's value changes....

We are fighting against that a long time...hehehe

Heeelp uuuuuss..

Thanks a lot...

Crigui.
 
Try the following code which had been used in my MDL program many times.

/*----------------------------------------------+
| name getAngleByTwoPt |
+----------------------------------------------*/
Public void getAngleByTwoPt(double *ang, Dpoint3d *pt1, Dpoint3d *pt2) { if (pt1->y == pt2->y)
*ang = (pt1->x > pt2->x) ? fc_zero : fc_pi;
else if (pt1->x == pt2->x)
*ang = ((pt1->y > pt2->y) ? fc_90 : fc_270) * fc_piover180; else if (pt1->x > pt2->x && pt1->y > pt2->y)
*ang = atan ((pt1->y - pt2->y) / (pt1->x - pt2->x)); else if (pt1->x < pt2->x && pt1->y > pt2->y)
*ang = fc_pi - atan ((pt1->y - pt2->y) / (pt2->x - pt1->x)); else if (pt1->x < pt2->x && pt1->y < pt2->y)
*ang = atan ((pt2->y - pt1->y) / (pt2->x - pt1->x)) + fc_pi; else if (pt1->x > pt2->x && pt1->y < pt2->y)
*ang = fc_2pi - atan ((pt1->y - pt2->y) / (pt2->x - pt1->x)); } /*----------------------------------------------+ | name getAngleFromTwoLineElms | +----------------------------------------------*/ Public double getAngleFromTwoLineElms (MSElement *elP1, MSElement *elP2) { DPoint3d pts[2]; double angle1, angle2; int numVerts;

mdlLinear_extract (pts, &numVerts, elP1, 0);
getAngleByTwoPt (&angle1, &pts[0], &pts[1]);
mdlLinear_extract (pts, &numVerts, elP2, 0);
getAngleByTwoPt (&angle2, &pts[0], &pts[1]);
return (angle1 - angle2);
}

NOTE: This code is only suitable for 2D design file!!!

Good Luck!

Foo.
 
Status
Not open for further replies.

Latest threads

Back
Top