Sign in to follow this  
Waterfox

Moving segments of a line.

Recommended Posts

So I have a line made of segments. Here's a pic (I forgot the end dot on the first line) http://img709.imageshack.us/img709/5228/71276566.jpg So it'll start off as a straight line and when the user moves the red dot with the mouse the entire line moves, and when the user rotates a blue dot, all the segments ahead of it and the one behind it will rotate on the dot 1 down in the line. How can I do this? I'm using Direct2D but it shouldn't be too hard to explain even if you haven't used it. So far I have one segment, this is what I've got so far.
		if(bluedot1_down)
		{
			angle=(float)atan2((double)d_mousePos.y-movPos.y,(double)d_mousePos.x-movPos.x)* 57.29f+90;
		}
		if(reddot_down)
		{
			movPos.x = (long)d_mousePos.x;
			movPos.y = (long)d_mousePos.y;
		}
	rotation = D2D1::Matrix3x2F::Rotation(angle, D2D1::Point2F(250.0f, 200.0f));
	translation = D2D1::Matrix3x2F::Translation((float)movPos.x-250, (float)movPos.y-200);
	RT->SetTransform(rotation* translation);
	RT->DrawLine(D2D1::Point2F(250, 200),D2D1::Point2F(250, 140),Black, 8, StrokeStyle);
	RT->DrawLine(D2D1::Point2F(250, 140),D2D1::Point2F(280, 170),Black, 8, StrokeStyle);

	RT->FillGeometry(bluedot1, Red);
	RT->FillGeometry(reddot, Orange);

I'm new to transformations so I'm kinda stuck on what comes next.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this