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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:11:33+00:00 2026-05-11T07:11:33+00:00

With reference to this programming game I am currently building. I am using WPF

  • 0

With reference to this programming game I am currently building.

I am using WPF to animate canvases, and I am using the BeginAnimation method to translate (move) a canvas across another canvas.

With the BeginAnimation, I need to specify the From and To coordinates for both x and y, and this is the method I am using this like such:

//X  Animator_Body_X.From = Translate_Body.X; //Current x-coordinate Animator_Body_X.To = //The end X-coordinate Translate_Body.BeginAnimation(TranslateTransform.XProperty, Animator_Body_X);  //Y Animator_Body_Y.From = Translate_Body.Y; //Current y-coordinate Animator_Body_Y.To = //The end Y-coordinate Translate_Body.BeginAnimation(TranslateTransform.YProperty, Animator_Body_Y); 

Now the canvas needs to be translated using a given angle, which I have available from the method.

So my question is, given the angle (0-359) the canvas is currently rotated at, starting x and y coordinates (of where the canvas is currently situated) and distance (in px), how do I calculate to end coordinates? ie to where the canvas will finally be translated to.

alt text http://img244.imageshack.us/img244/4794/canvastranspositionmi5.jpg

In the above image, I have drawn an example of what I want to achieve.

Suppose the canvas (solid-border box) has a current heading (angle) of 130 degrees, and it needs to be translated (following a path down that angle; ie depending on where it is currently facing) by 200 pixels…what will be the new coordinates (where it will stop animating: dashed-border box) of the canvas? How do I calculate these new coordinates of where it will stop?

[UPDATE] Solution:

Thanks to the help of both Andy and Cameron, it is finally working as intended.

And here is the working code:

double headingRadians = Heading * (Math.PI / 180);  Animator_Body_X.From = Translate_Body.X; Animator_Body_X.To = Math.Sin(headingRadians) * pix + Translate_Body.X; Translate_Body.BeginAnimation(TranslateTransform.XProperty, Animator_Body_X);  Animator_Body_Y.From = Translate_Body.Y; Animator_Body_Y.To = ((Math.Cos(headingRadians) * pix) * -1) + Translate_Body.Y; Translate_Body.BeginAnimation(TranslateTransform.YProperty, Animator_Body_Y); 
  • 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. 2026-05-11T07:11:33+00:00Added an answer on May 11, 2026 at 7:11 am

    Assuming you’re rotating clockwise from 12 o’clock, your new x-coordinate will be:

    sin(130) * 200 = 153 + original x-coordinate 

    And your new y-coordinate will be

    cos(130) * 200 = -129 + original y-coordinate (assuming negative 'y' is down) 

    As below, note that in C#, for example, sin and cos take radians, not degrees – multiply by Math.PI/180 to get the value in radians first.

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

Sidebar

Ask A Question

Stats

  • Questions 196k
  • Answers 196k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This user likely doesn't have the version of the .NET… May 12, 2026 at 7:10 pm
  • Editorial Team
    Editorial Team added an answer I got it. I just had to set the mbstring… May 12, 2026 at 7:10 pm
  • Editorial Team
    Editorial Team added an answer It turns out that in our case this was happening… May 12, 2026 at 7:10 pm

Related Questions

With reference to this programming game I am currently building. alt text http://img12.imageshack.us/img12/2089/shapetransformationf.jpg To
With reference to this programming game I am currently building. I wrote the below
With reference to this programming game I am currently building. Thanks to the answers
With reference to this programming game I am currently building. I have a Class

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.