Rotation over a point on a 2D pivot in Java

Asked

Viewed 66 times

-3

I’m trying to figure out how to rotate a vector over a point (another vector) as a PIVOT tried on some websites that gave me the following code:

public Vector2 rotate_point(float cx,float cy,float angle,Vector2 p)
{
  float s = (float) Math.sin(angle);
  float c = (float) Math.cos(angle);

  // translate point back to origin:
  p.x-= cx;
  p.y -= cy;

  // rotate point
  float xnew = p.x * c - p.y * s;
  float ynew = p.x * s + p.y * c;


  return p;
}

But I don’t understand what that variable would be Angle float.

  • PLEASE DO NOT USE HIGH BOX WITHOUT NEED. THANK YOU!!!!

  • It might be interesting to review the vector content before anything else. By the way, which programming language you want to analyze, Java or C++?

  • SORRY I DON’T KNOW WHAT HIGH CASH

  • Anderson-carlos-woss am using java ,had stopped with programming a long time ago ,I decided to return only a simple doubt I will revive vectors ,but obg by responds

  • CAIXA-ALTA is the use of everything in upper case, just note that the Leticia already set https://answall.com/posts/206068/revisions, really using everything in upper case is totally unnecessary and more disturbing than helping ;)

1 answer

-1


  • OK agr understood , WOW IS REALLY ,I AM SLOW IN MATHEMATICS

  • THANK YOU VERY MUCH GIRL HELPED ME VERY MUCH

  • By nd... Arrange :D

  • Wouldn’t it be better to copy the code the answer, otherwise this would be more for a comment.

  • He asked what the Angle float was, not how to do it... The link was just a suggestion from somewhere else to look...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.