Пример #1
0
Rectangle::Rectangle(Coordinates v1, Coordinates v2) {
	my_vertex[0] = v1;
	my_vertex[1] = Coordinates(v1.getAbs() , v2.getOrd());
	my_vertex[2] = Coordinates(v2.getAbs() , v1.getOrd());
	my_vertex[3] = v2;

	my_length = v1.distance(my_vertex[1]);	//determining edge length
	my_width = v2.distance(my_vertex[2]);	//determining edge length

	if(my_length<my_width ){
		float temp;
		temp=my_length;
		my_length= my_width;
		my_width = temp;
	}
	pos = (v2+v1)/2;
}
Пример #2
0
void Rectangle::rotate(Coordinates origin, float alpha) {
	for (unsigned int i(0) ; i<3 ; i++){
		my_vertex[i].setAbs( (my_vertex[i].getAbs()-origin.getAbs()) * cos(alpha)  - 	(my_vertex[i].getOrd() - origin.getOrd()) * sin (alpha) + origin.getAbs());
		my_vertex[i].setOrd ((my_vertex[i].getAbs()-origin.getAbs()) * sin(alpha)  + 	(my_vertex[i].getOrd() - origin.getOrd()) * cos (alpha) + origin.getOrd());
	}
}