Finding coordinates of rectangle on a curved surface

fes

Does anyone know how to calculate the coordinates of the rectangle/square box on the surface of the circle?

circle box

I can get the center of the rectangle and draw a line through it but trying to get the coordinates.

var lineHeight = 25;

var baseX = circle.x + circleRadius/2 * Math.cos(angleRadians);
var baseY = circle.y + circleRadius/2 * Math.sin(angleRadians);

var x1 = baseX + lineHeight*Math.cos(angleRadians);
var y1 = baseY + lineHeight*Math.sin(angleRadians);


this.testgraphics = this.add.graphics();
this.testgraphics.lineStyle(4, 0xff0000);
this.testgraphics.beginPath();
this.testgraphics.moveTo(baseX, baseY);
this.testgraphics.lineTo(x1, y1);
this.testgraphics.closePath();
this.testgraphics.strokePath();
MBo

Why do you use a half of circleRadius (circleRadius/2)?

baseX = circleCenterX + circleRadius * cos(angleRadians) 
baseY = circleCenterY + circleRadius * sin(angleRadians) 

corner coordinates

x1 = baseX - rectWidth / 2 * sin(angleRadians)   //note sign
y1 = baseY + rectWidth / 2 * cos(angleRadians) 

x2 = baseX - rectWidth / 2 * sin(angleRadians) + rectHeight * cos(angleRadians)  
y2 = baseY + rectWidth / 2 * cos(angleRadians) + rectHeight * sin(angleRadians) 

x3 = baseX + rectWidth / 2 * sin(angleRadians) + rectHeight * cos(angleRadians)  
y3 = baseY - rectWidth / 2 * cos(angleRadians) + rectHeight * sin(angleRadians)

x4 = baseX + rectWidth / 2 * sin(angleRadians) 
y4 = baseY - rectWidth / 2 * cos(angleRadians) 

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

finding the intersection of a line with an arbitrary surface?

From Dev

Finding coordinates of a character?

From Dev

get coordinates of a rectangle

From Dev

ZXing: Finding the bounding rectangle of Barcode

From Dev

Finding a square in a group of coordinates

From Dev

Finding Location / Coordinates in Dart

From Dev

Rectangle with curved sides and sharp corners

From Dev

How to model particle bouncing off of a curved surface in 3D?

From Dev

Finding rotated rectangle from contour

From Dev

SQL Finding the coordinates that belong to a circle

From Dev

How to move a rectangle in a curved path in pygames?

From Dev

Finding the midpoint of the rotated rectangle

From Dev

How to create a transparent curved transparent rectangle at center of the screen?

From Dev

finding the intersection of a line with an arbitrary surface?

From Dev

Finding Rectangle which contains a Point

From Dev

Finding coordinates of a character?

From Dev

ZXing: Finding the bounding rectangle of Barcode

From Dev

Finding coordinates of a point on a line

From Dev

Finding the vertices of a rectangle

From Dev

Finding the surface of the intersection between a rectangle and a triangle?

From Dev

Finding a rectangle and its corners in an image

From Dev

Rectangle Coordinates Not Updating

From Dev

Make rectangle with one side curved

From Dev

Finding rotated rectangle from contour

From Dev

Finding coordinates of the circumference of circle in pygame

From Dev

Generate random coordinates in a rectangle qt

From Dev

How to draw rectangle with one side curved in html

From Dev

Finding the biggest square in a rectangle with a condition

From Dev

Bounding rectangle for a triangle and normalized coordinates

Related Related

HotTag

Archive