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

  • SEARCH
  • Home
  • 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 7739273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:28:55+00:00 2026-06-01T08:28:55+00:00

I read the Calculate Bounding box coordinates from a rotated rectangle to know how

  • 0

I read the Calculate Bounding box coordinates from a rotated rectangle to know how to calculate bounding box coordinates from a rotated rectangle. But in a special case as follow image:

https://i.stack.imgur.com/3UNfD.png

How to get the rotated rectangle size if had get the bounding box size, coordinates and rotate degree?

I try write code in javascript

//assume w=123,h=98,deg=35 and get calculate box size
var deg = 35;
var bw = 156.9661922099485;
var bh = 150.82680201149986;

//calculate w and h
var xMax = bw / 2;
var yMax = bh / 2;
var radian = (deg / 180) * Math.PI;
var cosine = Math.cos(radian);
var sine = Math.sin(radian);
var cx = (xMax * cosine) + (yMax * sine)   / (cosine * cosine + sine * sine);
var cy =  -(-(xMax * sine)  - (yMax * cosine) / (cosine * cosine + sine * sine));
var w = (cx * 2 - bw)*2;
var h = (cy * 2 - bh)*2;

But…the answer is not match w and h

  • 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-06-01T08:28:56+00:00Added an answer on June 1, 2026 at 8:28 am

    enter image description here

    Solution

    Given bounding box dimensions bx by by and t being the anticlockwise rotation of rectangle sized x by y:

    x = (1/(cos(t)^2-sin(t)^2)) * (  bx * cos(t) - by * sin(t))
    y = (1/(cos(t)^2-sin(t)^2)) * (- bx * sin(t) + by * cos(t))
    

    Derivation

    Why is this?

    First, consider that the length bx is cut in two pieces, a and b, by the corner of the rectangle. Use trigonometry to express bx in terms of x, y, and theta:

    bx = b          + a
    bx = x * cos(t) + y * sin(t)            [1]
    

    and similarly for by:

    by = c          + d
    by = x * sin(t) + y * cos(t)            [2]
    

    1 and 2 can be expressed in matrix form as:

    [ bx ] = [ cos(t)  sin(t) ] * [ x ]     [3]
    [ by ]   [ sin(t)  cos(t) ]   [ y ]
    

    Note that the matrix is nearly a rotation matrix (but not quite – it’s off by a minus sign.)

    Left-divide the matrix on both sides, giving:

    [ x ] = inverse ( [ cos(t)  sin(t) ]    * [ bx ]                        [4]
    [ y ]             [ sin(t)  cos(t) ] )    [ by ]
    

    The matrix inverse is easy to evaluate for a 2×2 matrix and expands to:

    [ x ] = (1/(cos(t)^2-sin(t)^2)) * [ cos(t) -sin(t) ] * [ bx ]           [5]
    [ y ]                             [-sin(t)  cos(t) ]   [ by ]
    

    [5] gives the two formulas:

    x = (1/(cos(t)^2-sin(t)^2)) * (  bx * cos(t) - by * sin(t))             [6]
    y = (1/(cos(t)^2-sin(t)^2)) * (- bx * sin(t) + by * cos(t))
    

    Easy as pie!

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

Sidebar

Related Questions

I read the manual that filesize() is able to calculate file size from remote
The application does not calculate things, but does i/o, read files, uses network. I
I'm trying to calculate the similarity (read: Levenshtein distance ) of two images, using
I'm looking for a faster way to calculate GC content for DNA strings read
Read about Server push here . I want to push data to client from
Read (skimmed enough to get coding) through Erlang Programming and Programming Erlang . One
I read from some books that Phusion Passenger is the answer to easy Ruby
I am using Bio::PopGen::PopStats to calculate Wright's F st for each line I read
What is a simple piece of code to read a stored number, calculate interest
Hy! I need to calculate the distance between 2 GPS Points. I read this

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.