Judgment point relative to the straight line status (location)

xiaoxiao2021-03-06  38

The judgment point is in the left side of the line on the left side of the straight line. When the straight line is straight, the straight line is in the straight line, and it is a program. hope its good for U.S.. Please also give you guides, maybe many cases have not been considered

Algorithm: For special states (horizontal, vertical) for straight lines, so that the next straight line can be seen as a rectangular diagonal now considering the case of rectangular (two cases below) (diagonal) The straight line, the point of judgment (a, b)), now as long as it is judged to determine the size of B 'and B, the size of the value can be made online, the line left, the line right

The procedure is as follows: ///

/// judgment point relative to the straight state /// /// /// /// /// /// /// /// 0: Online 1: Online left 2: Online Right 3: Online Top 4: Online Public Int Ptinline (Double DPTX, Double Dpty, Double DLINEX1, Double DLiney2) {if (DLINEX1 == DLINEX2) {// Vertical IF (DPTX == DLINEX1) RETURN 0; if (DPTX

if (dLineX1 dLineY2) {return PtInLineStd_Up (dPtX, dPtY, dLineX1, dLineY1, dLineX2, dLineY2);} else {return PtInLineStd_Down (dPtX, dPtY, dLineX1, dLineY1, dLineX2, dLineY2);} } else {if (dLineY1> dLineY2) {return PtInLineStd_Down (dPtX, dPtY, dLineX2, dLineY2, dLineX1, dLineY1);} else {return PtInLineStd_Up (dPtX, dPtY, dLineX2, dLineY2, dLineX1, dLineY1);}}} // /

////////////// /// /// /// /// /// /// int ptinlinestd_up (Double DPTX, Double Dpty, Double DLINEX1, Double DLiney1, Double DLINEX2, DOUBLE DLINEY2) {Double DLEFT = (DPTY - DLINEY2) * (DLINEX2 - DLINEX1); Double Dright = (DLINEX2 - DPTX) * (DLINEY1 - DLINEY2); IF (DLEFT> DRI) GHT) RETURN 2; ELSE IF (DRIGHT> DLEFT) RETURN 1; Else Return 0;} /// ////////////////////////////////////// /// /// /// /// /// ///

int PtInLineStd_Down (double dPtX, double dPtY, double dLineX1, double dLineY1, double dLineX2, double dLineY2) {double dLeft = (dPtY - dLineY1) * (dLineX2 - dLineX1); double dRight = (dPtX - dLineX1) * (dLineY2 - dLineY1 ); If (DLEFT> dright) Return 1; Else IF (DRIGHT> DLEFT) RETURN 2; Else Return 0;} Attached: Code Posts True TMD is ugly

转载请注明原文地址:https://www.9cbs.com/read-64214.html

New Post(0)