开发者

How to find the postion of this point (canvas)?

开发者 https://www.devze.com 2023-03-11 07:12 出处:网络
http://img684.imagesha开发者_运维知识库ck.us/img684/9305/fffnv.png Do i need to solve a math, is there a easy way to solve this problem?First you compute the angle of the line from second to first po

http://img684.imagesha开发者_运维知识库ck.us/img684/9305/fffnv.png

Do i need to solve a math, is there a easy way to solve this problem?


First you compute the angle of the line from second to first point

var angle = Math.atan2(first.y - second.y, first.x - second.x);

then you compute the resulting point using sin and cos

var result = {x : second.x + z*Math.cos(angle + Math.PI/2),
              y : second.y + z*Math.sin(angle + Math.PI/2)};


Obviously you do need some math to get this going.

Math.atan ((y-y')/(x-x')) will get you the angle (in Radians) of the first line from the horrizon.

Add Pi/2 (90 degrees) to this angle to get the angle of the z line.

You can then use Math.sin and Math.cos `multiplied by z to find the coordinates of the third point.

0

精彩评论

暂无评论...
验证码 换一张
取 消