I have an object that is a circle. I want to be able to rotate the circle around it's center point which will always stay the same (currently I have it at 0,0,0). I can get two other points in space, basically a start point (x1,y1) and then an end point (x2,y2) based off of where the mouse is clicked and then where the mouse is dragged to. From this I can get the distance from the the center to the start and end point and from the stop to the end point to get a triangle. The problem from there is I'm not sure how I can calculate the angles. If I am thinking this through correctly I need to get the angles of the start point and end point and then use those to derive the angle of the center point. Then somehow set the rotation of the object to the angle of the center point. I have a little diagram below. I'm very dusty on my trig and still learning the Unity language so any help would be much appreciated! Here is the code I have so far, I'm stuck at how to get all three angles and then what I should use to apply the angle to a rotation once I find it.
show all comments
(comments are locked)

this is a 2d rotation? then you want to rotate around the y axis angle degrees angle can be found using the angle function angle = vector2.angle(from angle(or first click pos), to angle(second click) rotate(vector3.up, angle) if good mark as answered if you need more help comment.
(comments are locked)

Stil at a loss, would really appreciate any guidance even a push in the right direction.
unitygems.com
Read through most of that. Problem is I can't really use Quaternion.LookRotation because the location I would be looking at is a Vector2 not a Quaternion. Unless I'm missing something?
I can't imagine this is too difficult for someone familiar with how this works, but as I'm still learning I'm having a hard time wrapping my head around it.
TBC ... all you want to know is how to calculate the angle shown between the two lines
AB and AC
is that correct?
spark has given you the answer! just use the unity function "Angle"
Unity has amazingly helpful functions. often if you simply search on the WORD involved (eg "angle") you'll find it !
so it's Vector2.angle( BA, CA );
you shoudl TICK his answer if it helps to keep the board tidy, cheers!
So I played with the LookRotation a little bit more and I almost have it working. There is one problem, it turns the whole object to face the mouse rather than just turning it around the zaxis toward the mouse.
I tried limiting the x and y as per the example in unitygems, but then it just doesn't rotate at all.
Here is where I am at, if the x,y rotation can be stopped somehow and only the z rotation this would work perfectly.
using UnityEngine;
public class SpinWithMouse : MonoBehaviour { public Transform target; public float speed = 1f;
Vector3 startTouch; public float angle = 0f;
currentLoc = UICamera.currentTouch.pos; startTouch = currentLoc  mTrans.localPosition; }
Vector3 currentTouch = newLoc  mTrans.localPosition;
}