样例:http://www.zhaojz.com.cn/demo/draw9.html
复制代码 代码如下:
//画切线
//point 圆外的一点
//dot 圆心
//r 半径
function drawCircleTangent(point, dot, r){
//画辅助线-start
var color = 'DarkRed'; //切线的颜色
var color2 = "#ccc"; //其它辅助线的颜色
drawLine(dot, [dot[0]+9*r,dot[1]], {color: color2}); // 延长圆心所在的水平线
drawLine(dot, [dot[0],dot[1]-4*r], {color: color2}); // 画出圆心所在的垂直线
drawPoint({
pw:2,ph:2,color:'DarkRed',point: [dot[0]+9*r,dot[1],'x']
});
drawPoint({
pw:2,ph:2,color:'DarkRed',point: [dot[0],dot[1]-4*r,'y']
});
drawLine(point, [point[0],dot[1]], {color: color2}); // 画point到x轴的垂直线
drawLine(point, dot, {color: color2}); // 连接point与dot
drawLine([point[0]-2*r, point[1]], [point[0]+2*r, point[1]], {color: color2}); //画point所在的水平线
//画辅助线-end
//point.push('point');
drawPoint({
pw:2,ph:2,color:'DarkRed',point: point
});
//dot.push('centre');
var r_square = Math.pow(r,2); // r的平方
var point_v = point[1]-dot[1]; //point到x轴的距离的平方
var point_h = point[0]-dot[0]; //point到y轴的距离的平方
var c_square = Math.pow(point_v,2) + Math.pow(point_h,2); //point到圆心的距离的平方
var c = Math.sqrt(c_square); //point到圆心的距离
var sinA = Math.abs(point_v)/c; //sinA
var cosA = Math.abs(point_h)/c; //cosA
var b_square = c_square-r_square; //point到切点的距离的平方
var b = Math.sqrt(b_square); //point到切点的距离
var sinB = b/c; //sinB
var cosB = r/c; //cosB
//以圆心为坐标圆点,确定point所在的象限
var quadrant = 1; //默认值
var pm_h = point_h == 0? point_h: point_h/Math.abs(point_h); //水平方向
var pm_v = point_v == 0? point_v: point_v/Math.abs(point_v); //垂直方向
var hv = pm_h*pm_v; //相乘,-1时point在一三象限,+1时point在二四象限,0时point在轴上
switch(hv){
case 1:
if((pm_h+pm_v)==-2){
quadrant = 2; //第二象限
}else{
quadrant = 4; //第四象限
}
break;
case -1:
if((pm_h-pm_v)==-2){
quadrant = 3; //第三象限
}
break;
case 0:
if((pm_h+pm_v)==-1){ //point在x轴的负半轴或者y轴的正半轴时,断定point在第二象限
quadrant = 2;
}
if((pm_h+pm_v)==1){ //point在x轴的正半轴或者y轴的负半轴时,断定point在第四象限
quadrant = 4;
}
break;
default:
}
var sinC = 0;
var conC = 0;
var sinD = 0;
var conD = 0;
switch(quadrant){
case 1:
sinC = cosB*cosA+sinB*sinA; //sinC = sin(90+(B-A)) = cos(B-A) = cosB*cosA+sinB*sinA
conC = -(sinB*cosA-cosB*sinA); //cosC = cos(90+(B-A)) = -sin(B-A) = -(sinB*cosA-cosB*sinA)
sinD = -(cosA*cosB-sinA*sinB); //sinD = sin(270-(A+B))
conD = -(sinA*cosB+cosA*sinB); //conD = cos(270-(A+B))
break;
case 2:
sinC = -(cosB*cosA-sinB*sinA); //sinC = sin(-90+(A+B))
conC = sinA*cosB+cosA*sinB; //conC = cos(-90+(A+B))
sinD = cosA*cosB+sinA*sinB; //sinD = sin(90+(A-B))
conD = -(sinA*cosB-cosA*sinB); //conD = cos(90+(A-B))
break;
case 3:
sinC = -(cosA*cosB+sinA*sinB); //sinC = sin(-90+(A-B))
conC = -(sinA*cosB-cosA*sinB); //conC = cos(-90+(A-B))
sinD = (cosA*cosB-sinA*sinB);
conD = sinA*cosB+cosA*sinB;
break;
case 4:
sinC = cosA*cosB-sinA*sinB;
conC = -(sinA*cosB+cosA*sinB)
sinD = -(cosA*cosB+sinA*sinB); //sinD = sin(270+(A-B))
conD = (sinA*cosB-cosA*sinB); //conD = cos(270+(A-B))
break;
default:
}
var tangentPointA = [point[0]+b*conC, point[1]+b*sinC]; //切点A位置
drawLine(point, tangentPointA, {color: color}); //画出切线
drawLine(dot, tangentPointA, {color: color2}); //连接圆点与切点
//drawArc(point, 17, (quadrant ==1 ||quadrant==4?180:0)-(quadrant ==2 ||quadrant==3?(-1):1)*Math.asin(sinC)*180/Math.PI, 0);
var tangentPointB = [point[0]+b*conD, point[1]+b*sinD]; //切点B位置
drawLine(point, tangentPointB, {color: color}); //画出切线
drawLine(dot, tangentPointB, {color: color2}); //连接圆点与切点
//drawArc(point, 27, (quadrant ==1 ||quadrant==4?180:0)-(quadrant ==2 ||quadrant==3?(-1):1)*Math.asin(sinD)*180/Math.PI, 0);
drawPoint({ //描切点
pw:3,ph:3,color:'DarkRed',point: tangentPointA
});
drawPoint({ //描切点
pw:3,ph:3,color:'DarkRed',point: tangentPointB
});
//画辅助弧
//(quadrant ==1 ||quadrant==4?360:0)
drawArc(point, b, 60, (quadrant ==1 ||quadrant==4?180:0)-(quadrant ==2 ||quadrant==3?(-1):1)*Math.asin(sinC)*180/Math.PI-5);
}
js,画图,切线
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
稳了!魔兽国服回归的3条重磅消息!官宣时间再确认!
昨天有一位朋友在大神群里分享,自己亚服账号被封号之后居然弹出了国服的封号信息对话框。
这里面让他访问的是一个国服的战网网址,com.cn和后面的zh都非常明白地表明这就是国服战网。
而他在复制这个网址并且进行登录之后,确实是网易的网址,也就是我们熟悉的停服之后国服发布的暴雪游戏产品运营到期开放退款的说明。这是一件比较奇怪的事情,因为以前都没有出现这样的情况,现在突然提示跳转到国服战网的网址,是不是说明了简体中文客户端已经开始进行更新了呢?
更新日志
- Fine乐团《废墟游乐》[320K/MP3][105.13MB]
- 万山红.2009-花开原野万山红Vol.1-2【柏菲】2CD【WAV+CUE】
- 曾庆瑜1992-18首中英文经典全集[台湾派森][WAV整轨]
- 【上扬爱乐】群星-TheSoundsofLS35AVol.4情迷4【低速原抓WAV分轨】
- Fine乐团《废墟游乐》[Hi-Res][24bit 48kHz][FLAC/分轨][767.04MB]
- Cicada《回返 (十五周年自选集)》[320K/MP3][93.87MB]
- Cicada《回返 (十五周年自选集)》[Hi-Res][24bit 48kHz][FLAC/分轨][466.75MB]
- 郑智化.2024-不思议【智在上作】【FLAC分轨】
- 罗文.2015-NEW.XRCD精丫华星】【WAV+CUE】
- 许秋怡.1995-电影少女【丽音唱片】【FLAC分轨】
- 【中国艺术歌曲典藏】温雅欣《她比烟花寂寞》紫银合金SQCD【低速原抓WAV+CUE】
- 张国荣《FinalEncounter》头版限量编号MQA-UHQ[低速原抓WAV+CUE].
- 发烧萨克斯-雪国之春(SRS+WIZOR)[原抓WAV+CUE]
- 王铮亮《慢人理论》[320K/MP3][175.31MB]
- 王铮亮《慢人理论》[FLAC/分轨][524.11MB]