MHB How do I calculate the center of a square given its position and orientation?

  • Thread starter Thread starter sterlingm
  • Start date Start date
  • Tags Tags
    Center Square
AI Thread Summary
To calculate the center of a square given its top left corner, position, and orientation, the correct approach involves using trigonometric functions based on the square's rotation. The center coordinates can be derived using the formulas x_C = x_world + 0.1524*cos(orientation - 3π/4) and y_C = y_world + 0.1524*sin(orientation - 3π/4). It's crucial to adjust the angle based on the square's rotation direction; counter-clockwise rotation adds to the angle, while clockwise rotation subtracts from it. The initial confusion stemmed from using the wrong angle, which was resolved by clarifying the reference point and the angle of rotation. Understanding these calculations is essential for accurately determining the square's center in a 2D project.
sterlingm
Messages
2
Reaction score
0
Hi,

I want to find the world coordinates of the center of a square given:

-The top left corner is the reference point
-Its position relative to the world frame
-Its orientation relative to the world frame

The example that I have been using is that the square is at (0,2), has 0 orientation, and the distance to the center from the corner is 0.1524m in the x and y directions (Picture given).

View attachment 1868

This means that the center should be -0.1524, 1.8476. My closest way of doing it was:

x = x_world + (h*cos(-PI/4))
y = y_world + (h*sin(-PI/4))

h = 0.2155m for this example

However, this gives me the location of (0.1524, 1.8476). The x coordinate should be negative. I have tried numerous equations such as:

x = (x_world+h)*(cos(orientation - PI/4))
x = (x_world+h)*(cos(orientation + PI/4))
x = x_world*cos(orientation+PI/4)
(The y formulas being the same but replacing x with y and cos with sin)

However, none of these work. If anyone could help me out, that would be great. I feel like it should be so simple, but I can't seem to figure it out. The oddly specific example is not from homework, this is something I am working on for a hobbyist 2D project.
 

Attachments

  • square.png
    square.png
    808 bytes · Views: 113
Mathematics news on Phys.org
The angle you want to use is $$-\frac{3\pi}{4}$$

The center of the given square would then have the coordinates:

$$x_C=0+0.1524\cos\left(-\frac{3\pi}{4} \right)\approx-0.107763$$

$$y_C=2+0.1524\sin\left(-\frac{3\pi}{4} \right)\approx1.892237$$

It looks like your diagram gives the upper right corner as the reference point, and where you have $h$, this is where you should have the measure $0.1524$.
 
MarkFL said:
The angle you want to use is $$-\frac{3\pi}{4}$$

The center of the given square would then have the coordinates:

$$x_C=0+0.1524\cos\left(-\frac{3\pi}{4} \right)\approx-0.107763$$

$$y_C=2+0.1524\sin\left(-\frac{3\pi}{4} \right)\approx1.892237$$

It looks like your diagram gives the upper right corner as the reference point, and where you have $h$, this is where you should have the measure $0.1524$.

Thanks! I think the main problem was using -PI/3 rather than -3PI/4. I probably should have added an arrow to my diagram to show where the "front" of the square was. I added it here:

View attachment 1871

However, I forgot to mention one important detail. The square can rotate. So how does the angle change from -3PI/4 if the square can rotate?
 

Attachments

  • square.png
    square.png
    855 bytes · Views: 91
If the square rotates about the point (0,2) in a counter-clockwise direction, then add the angle of rotation to $$-\frac{3\pi}{4}$$. If the rotation is in a clockwise direction then subtract the angle of rotation.
 
Insights auto threads is broken atm, so I'm manually creating these for new Insight articles. In Dirac’s Principles of Quantum Mechanics published in 1930 he introduced a “convenient notation” he referred to as a “delta function” which he treated as a continuum analog to the discrete Kronecker delta. The Kronecker delta is simply the indexed components of the identity operator in matrix algebra Source: https://www.physicsforums.com/insights/what-exactly-is-diracs-delta-function/ by...
Fermat's Last Theorem has long been one of the most famous mathematical problems, and is now one of the most famous theorems. It simply states that the equation $$ a^n+b^n=c^n $$ has no solutions with positive integers if ##n>2.## It was named after Pierre de Fermat (1607-1665). The problem itself stems from the book Arithmetica by Diophantus of Alexandria. It gained popularity because Fermat noted in his copy "Cubum autem in duos cubos, aut quadratoquadratum in duos quadratoquadratos, et...
Thread 'Imaginary Pythagorus'
I posted this in the Lame Math thread, but it's got me thinking. Is there any validity to this? Or is it really just a mathematical trick? Naively, I see that i2 + plus 12 does equal zero2. But does this have a meaning? I know one can treat the imaginary number line as just another axis like the reals, but does that mean this does represent a triangle in the complex plane with a hypotenuse of length zero? Ibix offered a rendering of the diagram using what I assume is matrix* notation...
Back
Top