画箭头
$Xexit=trim($exit[0]);?????//始點x坐標
????????????????????????$Yexit=trim($exit[1]);?????//始點Y坐標
????????????????????????$Xenter=trim($enter[0]);?//終點X坐標
????????????????????????$Yenter=trim($enter[1]);?//終點Y坐標
????????????????????????imageline($im,$Xexit,$Yexit,$Xenter,$Yenter,$green);??//畫根線
????????????????????????if($Yexit?==?$Yenter)?????????
????????????????????????{
????????????????????????????????if($Xexit?<?$Xenter)????$included?=?0;
????????????????????????????????else????$included?=?180;
????????????????????????}
????????????????????????else?if($Xexit?==?$Xenter)
????????????????????????{
????????????????????????????????if($Yexit?<?$Yenter)????$included?=?270;
????????????????????????????????else????$included?=?90;
????????????????????????}
????????????????????????else
????????????????????????{
????????????????????????????????$slope=($Yenter?-?$Yexit)/($Xenter?-?$Xexit);
????????????????????????????????$included=atan($slope)*(180/$PI);
????????????????????????????????if($Yexit?<?$Yenter)????$included?+=?180;???//終點在下,可以確定這時角度應該等于180+斜率.
????????????????????????}
???????????????????????????????????????????????//?確定那跟直線的角度.???
??????????????????????????????????????????????//因為斜率只能是0-180度.所以就一點點的判斷了.
????????????????????????$Xpoint?=?(int)(($Xenter*7?+?$Xexit)/8);??//找出直線的某個位置用來畫箭頭用?X.坐標
????????????????????????$Ypoint?=?(int)(($Yenter*7?+?$Yexit)/8);??//找出直線的某個位置用來畫箭頭用?Y.坐標
????????????????????????$XpointUP?=?$Xpoint?+?(int)(cos($included?+?45)*10);?????//把那跟直線旋轉45度后的X坐標?,10是那個箭頭的長度.?????????????????
????????????????????????$YpointUP?=?$Ypoint?+?(int)(sin($included?+?45?)*10);??????//把那跟直線旋轉45度后的Y坐標?????
????????????????????????ImageLine($im,$XpointUP,$YpointUP,$Xpoint,$Ypoint,$green);??//畫線.....????
????????????????????????$Yexit=trim($exit[1]);?????//始點Y坐標
????????????????????????$Xenter=trim($enter[0]);?//終點X坐標
????????????????????????$Yenter=trim($enter[1]);?//終點Y坐標
????????????????????????imageline($im,$Xexit,$Yexit,$Xenter,$Yenter,$green);??//畫根線
????????????????????????if($Yexit?==?$Yenter)?????????
????????????????????????{
????????????????????????????????if($Xexit?<?$Xenter)????$included?=?0;
????????????????????????????????else????$included?=?180;
????????????????????????}
????????????????????????else?if($Xexit?==?$Xenter)
????????????????????????{
????????????????????????????????if($Yexit?<?$Yenter)????$included?=?270;
????????????????????????????????else????$included?=?90;
????????????????????????}
????????????????????????else
????????????????????????{
????????????????????????????????$slope=($Yenter?-?$Yexit)/($Xenter?-?$Xexit);
????????????????????????????????$included=atan($slope)*(180/$PI);
????????????????????????????????if($Yexit?<?$Yenter)????$included?+=?180;???//終點在下,可以確定這時角度應該等于180+斜率.
????????????????????????}
???????????????????????????????????????????????//?確定那跟直線的角度.???
??????????????????????????????????????????????//因為斜率只能是0-180度.所以就一點點的判斷了.
????????????????????????$Xpoint?=?(int)(($Xenter*7?+?$Xexit)/8);??//找出直線的某個位置用來畫箭頭用?X.坐標
????????????????????????$Ypoint?=?(int)(($Yenter*7?+?$Yexit)/8);??//找出直線的某個位置用來畫箭頭用?Y.坐標
????????????????????????$XpointUP?=?$Xpoint?+?(int)(cos($included?+?45)*10);?????//把那跟直線旋轉45度后的X坐標?,10是那個箭頭的長度.?????????????????
????????????????????????$YpointUP?=?$Ypoint?+?(int)(sin($included?+?45?)*10);??????//把那跟直線旋轉45度后的Y坐標?????
????????????????????????ImageLine($im,$XpointUP,$YpointUP,$Xpoint,$Ypoint,$green);??//畫線.....????
畫出來的線很亂,沒有旋轉45度后的效果.??
我這個是什么地方出錯了啊?????
謝謝大家指點?
看圖b,可以看到還是我的位置沒有確定對..?
是坐標系的轉換問題引起的嗎???
數學中有?1?,?2?,3?,4象限,對應的cos和sin會有正負,而計算機中的這個是以角為基準.不斷增大的.就象是第一象限以x軸為中線畫的對稱圖形,向下遞增.
轉載于:https://www.cnblogs.com/yibaidian/p/4118623.html
總結
- 上一篇: 又是一年国庆假期最后一天
- 下一篇: 找不到/boot目录grub命令行启动以