【发布时间】:2019-03-17 00:05:01
【问题描述】:
假设我有一个等边三角形 abc,它具有三个坐标 A(40,60)、B(70,30)、C(50,80),如图所示。 Triangle with it's Coordinates
我想找到一个与所有点相交的坐标,让这个坐标为 D(x,y) 如图: Intersected Coordinate D with other Coordinates
假设AD平行于bc,BD平行于ab,DC平行于ac。请帮忙找坐标D。 到目前为止,我能够使用 HTML 画布定位三角形上的三个点,但无法连接所有坐标以形成 D 坐标。 所有坐标都是像素值。 制作三角形:
var v0={x:114,y:366};
var v1={x:306,y:30};
var v2={x:498,y:366};
var triangle=[v0,v1,v2];
drawTriangle(triangle);
function drawTriangle(t){
ctx.beginPath();
ctx.moveTo(t[0].x,t[0].y);
ctx.lineTo(t[1].x,t[1].y);
ctx.lineTo(t[2].x,t[2].y);
ctx.closePath();
ctx.strokeStyle='black';
ctx.lineWidth=2;
ctx.stroke();
}
在三角形上绘制坐标的函数。 x,y 坐标是随机取的。
function drawCoordinates(x,y){
ctx.fillStyle = "red"; // Red color
ctx.beginPath();
ctx.arc(x, y, pointSize, 0, Math.PI * 2, true);
ctx.fill();
//For Drwaing Cords
//drawCords(x,y);
}
有没有办法通过满足这个平行条件来连接这三个点形成D。请帮忙。如果您需要任何进一步的说明,也请提出建议,我是这种 HTML 画布技术的新手。
【问题讨论】:
-
我投票结束这个问题,因为它是数学问题
标签: javascript html html5-canvas