简体   繁体   English

如何找到某一点的角度

[英]how to find the angle of the certain point

I drawn the svg circle using start and endangle as follow, 我使用start和endangle绘制了svg圈,如下所示,

document.getElementById("circle").setAttribute("d", describeArc(150, 150, 100, 180, 360));
            function getPathArc(center, start, end, radius) {
                        end = end - 0.0001;
                        var degree = end - start;
                        degree = degree < 0 ? (degree + 360) : degree;
                        var clockWise = (degree < 180) ? 0 : 1;
                        return getPiePath(center, degreeToLocation(start, radius, center), degreeToLocation(end, radius, center), radius, clockWise);
            }
            function getPiePath(center, start, end, radius, clockWise) {
                        return 'M ' + start.x + ' ' + start.y + ' A ' + radius + ' ' + radius + ' 0 ' + clockWise + ' 1 ' + end.x + ' ' + end.y;
            };          
            function degreeToLocation(degree, radius, center) {
                    var radian = (degree * Math.PI) / 180;
                    return { 
                        'x' : Math.cos(radian) * radius + center.x,
                        'y': Math.sin(radian) * radius + center.y
                    };
            }           
            function describeArc(x, y, radius, startAngle, endAngle){
                var endAngle = endAngle - startAngle;
                startAngle = startAngle <= 0 ? (360 + startAngle) % 360 : startAngle % 360;
                endAngle = endAngle < 0 ? (360 + endAngle + startAngle) % 360 : Math.abs(endAngle + startAngle) % 360;
                    var direction = getPathArc({'x': x, 'y': y}, startAngle, endAngle, radius);
                    var d = direction;
                    return d;       
            }

here is the sample https://jsfiddle.net/ndmsqmao/3/ 这是样本https://jsfiddle.net/ndmsqmao/3/

i need to draw the one tick line for that circle for specified point. 我需要为指定点绘制该圆圈的一个刻度线。

for example let us consider, 比如让我们考虑一下,

if it's value is start from 50 to 100 mean i need to draw the one tick line for 66th value.. how to acheive this? 如果它的值从50到100开始意味着我需要绘制第66个值的一个刻度线..如何实现这个?

在此输入图像描述

Hope this helps... 希望这可以帮助...

var minValue = 50, maxValue = 100, value = 66,
    minAngle = 180, maxAngle = 360, angle;

angle = minAngle + (value - minValue) / (maxValue - minValue) * (maxAngle - minAngle);

alert(angle);

I hope i understand your Question... 我希望我理解你的问题......

var min = 50;
var max = 100;
var value = 66;

var angle = 180/(max-min)*(value-min)+180;

console.log (angle);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何弹跳点以一定角度击中线 - How to bounce a point to hit a line with a certain angle 如何找到给定角度和距离的第三点 - How to find third point with given angle and distance 如何找到一个点坐标,它的起点,宽度和角度与X有关 - how to find a point coordinates having it's start point, width and angle related to X 如何计算鼠标指针存在于某个点的角度? - How do I calculate the angle at which mouse pointer is present to a certain point? 找到具有原点、角度和半径的点的位置 - find position of a point with origin, angle and radius 以与不在矩形中间的点成一定角度的角度找到矩形边界点 - Find rectangle boundary point at an angle from point that is not in the middle of the rectangle 给定 3D 空间中的一条线,我如何找到从它到点的角度? - Given a line in 3D space, how do I find the angle from it to a point? 如何从JavaScript中任意角度的两点找到等边三角形的第三点? - How to find 3rd point of equilateral triangle from two points at any angle in JavaScript? 所以我有一个三角形,点(100,90)距离(11)和线的角度(45°)我可以找到该线的另一个点吗? 怎么样? - So I have a triangle with the point (100, 90) the distance (11) and the angle of the line (45º) Can I find the other point of the line? How? 如何将任意点旋转任意角度? - How to rotate any point by any angle?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM