简体   繁体   English

如何计算圆与等边三角形的6个交点的坐标?

[英]How to calculate coordinates of 6 point of intersection between a circle and a equilateral triangle?

I know of an equilateral triangle the center (cx,cy) and the radius (r) of a blue circle which conscripts it.我知道一个等边三角形的中心 (cx,cy) 和一个蓝色圆圈的半径 (r) 征用它。

If I draw a green circle of any radius (radius), assuming the circle is large enough to have this intersection, can I get the coordinates of the 6 intersection points (P1, P2, P3...)?如果我画一个任意半径(radius)的绿色圆圈,假设这个圆圈大到有这个交点,我能得到6个交点(P1,P2,P3...)的坐标吗?

文本

I'm looking for P5JS/processing but any other clue can help me...我正在寻找 P5JS/processing 但任何其他线索都可以帮助我......

Thank you in advance先感谢您

Distance from the center to top point is r .从中心到顶点的距离是r
Distance from the center to the lowest triangle side is r/2 (median intersection point is center, they are divided in 1:2 ratio).中心到三角形最低边的距离为r/2 (中间交点为中心,按1:2比例划分)。
Horizontal distance from cx to p4 (and p5) is (Pythagoras' theorem)cxp4 (和 p5)的水平距离是(毕达哥拉斯定理)

dx = sqrt(radius^2 - r^2/4)

So coordinates of p4 and p5 are (relative to center)所以p4p5的坐标是(相对于中心)

p4x = dx
p4y = r/2
p5x = -dx
p5y = r/2

Other points might be calculated using rotation by 120 degrees其他点可以使用旋转 120 度来计算

p2x = p4x*(-1/2) - p4y*(sqrt(3)/2)
p2y = p4x*(sqrt(3)/2) + p4y*(-1/2)

and so on.等等。

And finally add cx,cy to get absolute coordinates最后加上cx,cy得到绝对坐标

If you want to test... ;-)如果你想测试......;-)

 function setup() { createCanvas(500, 500); const cx = width / 2; const cy = height / 2; const r = 250; // taille du triangle const radius = 180; // externe noFill(); strokeWeight(3); stroke(0, 0, 0); drawTriangle(cx, cy, r); strokeWeight(1); stroke(0, 0, 255); circle(cx, cy, r * 2); strokeWeight(2); stroke(8, 115, 0); circle(cx, cy, radius * 2); noStroke(); fill(215, 0, 0); dx = sqrt(Math.pow(r / 2, 2) - Math.pow(r / 2, 2 / 4)); p4x = dx; p4y = r / 2; circle(cx + p4x, cy + p4y, 20); text("p4", cx + p4x, cy + p4y + 30); p5x = -dx; p5y = r / 2; circle(cx + p5x, cy + p5y, 20); text("p5", cx + p5x - 10, cy + p5y + 30); p6x = p4x * (-1 / 2) - p4y * (sqrt(3) / 2); p6y = p4x * (sqrt(3) / 2) + p4y * (-1 / 2); circle(cx + p6x, cy + p6y, 20); text("p6", cx + p6x - 30, cy + p6y); p2x = p6x * (-1 / 2) - p6y * (sqrt(3) / 2); p2y = p6x * (sqrt(3) / 2) + p6y * (-1 / 2); circle(cx + p2x, cy + p2y, 20); text("p2", cx + p2x + 10, cy + p2y - 10); p1x = p5x * (-1 / 2) - p5y * (sqrt(3) / 2); p1y = p5x * (sqrt(3) / 2) + p5y * (-1 / 2); circle(cx + p1x, cy + p1y, 20); text("p1", cx + p1x - 20, cy + p1y - 10); p3x = p1x * (-1 / 2) - p1y * (sqrt(3) / 2); p3y = p1x * (sqrt(3) / 2) + p1y * (-1 / 2); circle(cx + p3x, cy + p3y, 20); text("p3", cx + p3x + 20, cy + p3y - 10); noFill(); stroke(0, 255, 255); triangle(cx + p2x, cx + p2y, cx + p4x, cx + p4y, cx + p6x, cx + p6y); stroke(255, 0, 255); // prettier-ignore triangle( cx + p1x, cx + p1y, cx + p3x, cx + p3y, cx + p5x, cx + p5y, ) } function drawTriangle(cx, cy, radius) { noFill(); trianglePoints = []; for (var i = 0; i < 3; i++) { var x = cx + radius * cos((i * TWO_PI) / 3.0 - HALF_PI); var y = cy + radius * sin((i * TWO_PI) / 3.0 - HALF_PI); trianglePoints[i] = { x, y, }; } triangle( trianglePoints[0].x, trianglePoints[0].y, trianglePoints[1].x, trianglePoints[1].y, trianglePoints[2].x, trianglePoints[2].y ); }
 <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.5.0/p5.min.js"></script>

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

相关问题 圆与线的交点(极坐标) - Intersection point between circle and line (Polar coordinates) 计算最接近2个圆之间交点的圆的坐标 - Calculate coordinates of circle that best approximates intersection between 2 circles 如何在C中找到2d等边三角形的坐标? - How to find coordinates of a 2d equilateral triangle in C? 计算圆和三角形的交点区域? - Compute the area of intersection between a circle and a triangle? 如何使用p5.js计算圆上线的交点 - How to calculate intersection point of a line on a circle using p5.js 如何确定直线与圆的交点? - How to determine the intersection point between the straight line and circle? 从任意角度的两个点计算等边三角形的第三个点,指出科赫雪花的“正确”方式 - Calculate the 3rd point of an equilateral triangle from two points at any angle, pointing the “correct” way for a Koch Snowflake Python函数来找到等边三角形的一个点 - Python function to find a point of an equilateral triangle 贝塞尔曲线与圆的交点 - Point of intersection between bezier curve and circle 给定三个点的坐标,如何确定所定义的三角形是等边,等腰还是斜角? - Given the coordinates of three points, how to determine if the triangle defined is equilateral, isosceles or scalene?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM