ObjectARX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

AcGeVector3d question?

2 REPLIES 2
Reply
Message 1 of 3
Mike_B
236 Views, 2 Replies

AcGeVector3d question?

What is the easiest way to tell if two lines are going in the same direction.

Eg: P1 & P2
P1 startPoint = 0,0,0 end point = 1,0,0
P2 startPoint = -1,0,0 end point = 0,0,0

They are actually going away from each other. How can I tell using Vectors?

Any help?

Mike Bujak
2 REPLIES 2
Message 2 of 3
Anonymous
in reply to: Mike_B

Here is a test code, it might help:

ads_point pt1, pt2, pt3, pt4;
acedGetPoint(NULL, "\nLine from: ", pt1);
acedGetPoint(pt1, "\nLine to: ", pt2);

acedGetPoint(NULL, "\nLine from: ", pt2);
acedGetPoint(pt2, "\nLine to: ", pt3);

AcGePoint3d ptA( pt1, pt1, pt1 );
AcGePoint3d ptB( pt2, pt2, pt2 );

AcGePoint3d ptC( pt3, pt3, pt3 );
AcGePoint3d ptD( pt4, pt4, pt4 );

AcGeLine3d line1(ptA,ptB) , line2(ptC,ptD);

AcGeVector3d v1 = line1.direction();
AcGeVector3d v2 = line2.direction();

if ( v1.angleTo(v2) != v2.angleTo(v1) ){
acutPrintf("\nSame direction");
}
else {
acutPrintf("\nNot the same direction");
}




--
http://www.geometricad.com



wrote in message news:5097904@discussion.autodesk.com...
What is the easiest way to tell if two lines are going in the same
direction.

Eg: P1 & P2
P1 startPoint = 0,0,0 end point = 1,0,0
P2 startPoint = -1,0,0 end point = 0,0,0

They are actually going away from each other. How can I tell using Vectors?

Any help?

Mike Bujak
Message 3 of 3
Anonymous
in reply to: Mike_B

Mike_B schrieb:

Hi Mike,
> What is the easiest way to tell if two lines are going in the same direction.
>
> Eg: P1 & P2
> P1 startPoint = 0,0,0 end point = 1,0,0
> P2 startPoint = -1,0,0 end point = 0,0,0
>
> They are actually going away from each other. How can I tell using Vectors?

You can use AcGeVector3d::isCodirectionalTo()

AcGeVector3d v1 = endpoint1-startpoint1;
AcGeVector3d v2 = endpoint2-startpoint2;
if (v1.isCodirectionalTo(v2))
....

HTH
Arnold

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost