Skip to main content
added 544 characters in body; deleted 6 characters in body
Source Link
Harold
  • 570
  • 4
  • 14

You could try

publicprivate Vector2 Rotate(float angle, float distance, vector2Vector2 centre)
{
    return new Vector2((float)(distance * Math.cosCos(angle)), (float)(distance * Math.sinSin(angle))) + centre;
}

Keep in mind I'm not at a computer I could test this on but that should be in the right direction

Edit: Checked it, works fine

Edit 2: Something else cool you could do:

public Vector2 Rotate(float angle, Vector2 currentPos, Vector2 centre)
{
    double distance = Math.Sqrt(Math.Pow(currentPos.X-centre.X, 2) + Math.Pow(currentPos.Y-centre.Y, 2));
    return new Vector2((float)(distance * Math.Cos(angle)), (float)(distance * Math.Sin(angle))) + centre;
}

That way you put in the angle you'd like to be rotated to, the position you're currently at and the the central point you'd like to be rotated around

You could try

public Vector2 Rotate(float angle, float distance, vector2 centre)
{
    return new Vector2(distance * Math.cos(angle), distance * Math.sin(angle)) + centre;
}

Keep in mind I'm not at a computer I could test this on but that should be in the right direction

Edit: Checked it, works fine

You could try

private Vector2 Rotate(float angle, float distance, Vector2 centre)
{
    return new Vector2((float)(distance * Math.Cos(angle)), (float)(distance * Math.Sin(angle))) + centre;
}

Keep in mind I'm not at a computer I could test this on but that should be in the right direction

Edit: Checked it, works fine

Edit 2: Something else cool you could do:

public Vector2 Rotate(float angle, Vector2 currentPos, Vector2 centre)
{
    double distance = Math.Sqrt(Math.Pow(currentPos.X-centre.X, 2) + Math.Pow(currentPos.Y-centre.Y, 2));
    return new Vector2((float)(distance * Math.Cos(angle)), (float)(distance * Math.Sin(angle))) + centre;
}

That way you put in the angle you'd like to be rotated to, the position you're currently at and the the central point you'd like to be rotated around

added 32 characters in body
Source Link
Harold
  • 570
  • 4
  • 14

You could try

public Vector2 Rotate(float angle, float distance, vector2 centre)
{
    return new Vector2(distance * Math.cos(angle), distance * Math.sin(angle)) + centre;
}

Keep in mind I'm not at a computer I could test this on but that should be in the right direction

Edit: Checked it, works fine

You could try

public Vector2 Rotate(float angle, float distance, vector2 centre)
{
    return new Vector2(distance * Math.cos(angle), distance * Math.sin(angle)) + centre;
}

Keep in mind I'm not at a computer I could test this on but that should be in the right direction

You could try

public Vector2 Rotate(float angle, float distance, vector2 centre)
{
    return new Vector2(distance * Math.cos(angle), distance * Math.sin(angle)) + centre;
}

Keep in mind I'm not at a computer I could test this on but that should be in the right direction

Edit: Checked it, works fine

changed name of function
Source Link
Notabene
  • 6.1k
  • 1
  • 33
  • 40

You could try

public Vector2 NewPositionRotate(float angle, float distance, vector2 centre)
{
    return new Vector2(distance * Math.cos(angle), distance * Math.sin(angle)) + centre;
}

Keep in mind I'm not at a computer I could test this on but that should be in the right direction

You could try

public Vector2 NewPosition(float angle, float distance, vector2 centre)
{
    return new Vector2(distance * Math.cos(angle), distance * Math.sin(angle)) + centre;
}

Keep in mind I'm not at a computer I could test this on but that should be in the right direction

You could try

public Vector2 Rotate(float angle, float distance, vector2 centre)
{
    return new Vector2(distance * Math.cos(angle), distance * Math.sin(angle)) + centre;
}

Keep in mind I'm not at a computer I could test this on but that should be in the right direction

Source Link
Harold
  • 570
  • 4
  • 14
Loading