C++ guru please help

AVForums

Help Support AVForums:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.

2wice

AVForums Grandmaster
*
Joined
Apr 8, 2013
Messages
3,132
Reaction score
263
Location
South Africa
I've been herding some cats over my keyboard and came up with some code.
It translates and rotates (x,y) points for trilateration
And then I have to reverse the operation to get the valid points.

Code:
//tranlate all towers down so that Tower3(Gamma) lies on (0,0)
	float ttower1_x = delta_tower1_x;
	float ttower1_y = delta_tower1_y - arm_radius;
	float ttower2_x = delta_tower2_x;
	float ttower2_y = delta_tower2_y - arm_radius;
	float ttower3_x = delta_tower3_x;
	float ttower3_y = delta_tower3_y - arm_radius;

	//Rotate all towers around (0,0) so that towers 3 & 2 lie on the x-axis
	float rtower1_x = ttower1_x * COS60 - ttower1_y * SIN60;
	float rtower1_y = ttower1_x * SIN60 + ttower1_y * COS60;
	float rtower2_x = ttower2_x * COS60 - ttower2_y * SIN60;
	float rtower2_y = ttower2_x * SIN60 + ttower2_y * COS60;
	float rtower3_x = ttower3_x;      //already on (0,0)
	float rtower3_y = ttower3_y;      //already on (0,0)

Is there a more elegant or correct way of doing this please?
 

Latest posts

Top