0 Replies - 552 Views - Last Post: 12 April 2021 - 06:34 AM Rate Topic: -----

#1 gorana   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 06-January 21

math - Turn one object around another

Posted 12 April 2021 - 06:34 AM

I have two rounds pt1 (0.0f, 0.0f, 0.0f) and pt2 (1.5f, 0.0f, 0.0f). pt2 revolves around pt1. I want to increase the radius relative to the current position pt2. It now moves only half a circle from right to top left then stops.

case VK_DOWN:
{
	Vector3		a	= pt2.pos - pt1.pos,
				b( 1.0f, 0.0f, 0.0f );

	float	dot		= a.dot( b ),
			lenA	= a.length(),
			lenB	= b.length(),
			rad		= acos( dot / (lenA * lenB) );

	float	thetaOne	= (PI * 2.0f) / 45;		// 45 - segments

	rad	+= thetaOne;
	pt2.SetTranslate( 1.5f * cosf( rad ), 1.5f * sinf( rad ), 0.0f );
}



Is This A Good Question/Topic? 0
  • +

Page 1 of 1