Assuming you want to rotate a point around another point, it is hard to tell from this snipped what you are doing: The problem with your math is that you are using the vector instead of the magnitude of the vector.
First, sin and cos depends on the rotation direction, so if you are using clockwise rotation then you were correct from the start. If not you need to reverse it.
So this part:
float angleRad = DEGREES_TO_RADIANS(rotationDegrees);
float offsetX = sin(angleRad) * mOffset.x;
float offsetY = cos(angleRad) * mOffset.y;
// This is what it should be
float angleRad = DEGREES_TO_RADIANS(rotationDegrees);
float offsetX = sin(angleRad) * mOffset.magnitude;
float offsetY = cos(angleRad) * mOffset.magnitude;
To calculate magnitude you can use pythagoras theorem. https://en.wikipedia.org/wiki/Pythagorean_theorem It is just Root((A*A) + (B*B))
Note: @Michael LaserBlade Scoggin method should be better on performance if it works for you , because calculating root is slow-ish.
Tried and tested Unity script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RotateAround : MonoBehaviour {
public GameObject Target;
public float RotationInDegree = 30f;
Vector3 Offset = Vector3.zero;
// Use this for initialization
void Start () {
Offset = Target.transform.position - this.transform.position;//This should be captured once
}
// Update is called once per frame
void Update () {
this.transform.position =
(new Vector3(Mathf.Sin(RotationInDegree*Mathf.Deg2Rad), Mathf.Cos(RotationInDegree * Mathf.Deg2Rad), 0f)* Offset.magnitude);
}
}