Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1003601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:00:19+00:00 2026-05-16T08:00:19+00:00

i’m stuck with a seemingly simple problem in mathematics: i need to rotate points

  • 0

i’m stuck with a seemingly simple problem in mathematics: i need to rotate points in a 2-dimensional cartesian coordinate system, i.e. i have a point given by (x/y) and an angle gamma and i need to get the coordinates of this point if rotated by gamma…

example: if x = 2 and y = 0 and the angle of rotation is 90°, the resulting point would be x’ = 0, y’ = -2 (rotated clockwise)

so i found this formula on the net (http://en.wikipedia.org/wiki/Rotation_matrix) and implemented some code to test it:

$x = 1; echo "x: " . $x . "<br>";
$y = 1; echo "y: " . $y . "<br>";
$gamma = 45; echo "gamma: " . $gamma . "<br>";

$sinGamma = sin(deg2rad($gamma));
$cosGamma = cos(deg2rad($gamma));

$x2 = $x*$cosGamma - $y*$sinGamma; echo "x2: " . $x2 . "<br>";
$y2 = $y*$cosGamma + $x*$sinGamma; echo "y2: " . $y2 . "<br>";

while this works just GREAT for angles of 90/180/270 degrees, anything else would result in total crap!

i.e.:

if x=1 and y=1 and gamma=45°, the resulting point would lay exactly on the x-axis… well – the script above would output:

x: 1
y: 1
gamma: 45
x2: 1.11022302463E-16
y2: 1.41421356237

did i understand sth wrong? (school’s over a long time for me ^^) how do i get this right?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T08:00:19+00:00Added an answer on May 16, 2026 at 8:00 am

    Your numbers actually look pretty much right there — (1,1) rotated 45 degrees around the origin would be (0, sqrt(2)). x2 looks odd because of the 1 in front, but the E-16 means the number’s actually .000000000000000111022 or something like that. And sqrt(2) comes out to somewhere around 1.414.

    You’re not going to get exact results due to floating-point rounding error (not to mention you’re working with irrational numbers).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.