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 8478241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:41:30+00:00 2026-06-10T18:41:30+00:00

I am trying to get 4 Vector2 objects representing the 4 corners of a

  • 0

I am trying to get 4 Vector2 objects representing the 4 corners of a sprite to rotate around the sprite itself rotates around its center. With my following code, however, the Vector2 objects rotate around 0,0 in Client Space instead of rotating around the center of the object. Using matrix transformations, is there any way to rotate the Vector2 objects around the center of the object instead of the global coordinate (0,0)?

Here is the function for the rotation so far:

public Vector2[] CheckCollision()
    {
        //Get the 4 corners of the sprite locally
        //We can get all 4 corners from only 2 vectors
        Vector2 topLeft = new Vector2(position.X - spriteSize.X, position.Y - spriteSize.Y);

        //Not sure why position is representing the
        //bottom right instead of the center here....
        Vector2 bottomRight = position;

        Vector2 bottomLeft = new Vector2(topLeft.X, bottomRight.Y);

        Vector2 topRight = new Vector2(bottomRight.X, topLeft.Y);

        //Create transformation matrix
        Matrix transform = Matrix.CreateRotationZ(MathHelper.ToRadians(this.direction)) *
            Matrix.CreateScale(this.scale);

        //Transform the vectors
        topLeft = Vector2.Transform(topLeft, transform);
        bottomRight = Vector2.Transform(bottomRight, transform);
        bottomLeft = Vector2.Transform(bottomLeft, transform);
        topRight = Vector2.Transform(topRight, transform);

        Vector2[] vectorArray = new Vector2[4];

        vectorArray[0] = topLeft;
        vectorArray[1] = bottomRight;
        vectorArray[2] = bottomLeft;
        vectorArray[3] = topRight;

        return vectorArray;

    }
  • 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-10T18:41:32+00:00Added an answer on June 10, 2026 at 6:41 pm

    It would probably be a lot easier to just rotate the four corners first before adding the spritePosition and add the spriteposition after the rotation and scaling has been performed.

    Just make your four corners into the corresponding combinations of spriteSize and do the Vector2.Transform once that is done add the spritePosition to the four vectors in vectorArray

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

Sidebar

Related Questions

I'm trying to get my head around solving the following problem. I have the
I'm playing around a bit and trying to get some things to work for
I am trying to get a vector to store objects of class 'Complex'. This
I'm trying to get my head wrapped around tangent space and I'm starting to
So i am trying get 2 div-containers which both should contain centered text (Both
I'm trying get the visible portion of UIImage from an UIImageView . UIImageView takes
I am trying get all html links within a string and replace them using
I am trying get all html links within a string and replace them using
I am trying get Struts 2 and Tiles to work and I am using
Trying to get a wildcard search to pick up on any text in org_name

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.