void viewControl_MouseMove(object sender, MouseEventArgs e) { Geom.Point2i p = new Geom.Point2i(e.X, e.Y); if ((e.Button & MouseButtons.Left) != 0 && p != _prevPos) { Graphics.ICamera camera = viewControl.Camera; Geom.Vector3d vec = camera.ScreenToCamera(p - _prevPos); Geom.Vector3d axis = Geom.Vector3d.Ez * vec; double depth = 0.5 * camera.ViewingDepth; double theta = System.Math.Atan2(vec.Length, depth); Geom.Rotation3d rot = new Geom.Rotation3d(axis.Normalize(), theta); Geom.HmCod3d c = this.ActiveLight.Position; Geom.Vector3d d = new Geom.Vector3d(c.X, c.Y, c.Z); d = rot.Rotate(d); this.ActiveLight.Position = new Geom.HmCod3d(d.x, d.y, d.z, 0.0); viewControl.Invalidate(); _docviews.Invalidate(); } _prevPos = p; }
void viewControl_MouseMove( object sender, MouseEventArgs e ) { Geom.Point2i p = new Geom.Point2i( e.X, e.Y ); if ( (e.Button & MouseButtons.Left) != 0 && p != _prevPos ) { Graphics.ICamera camera = viewControl.Camera; Geom.Vector3d vec = camera.ScreenToCamera( p - _prevPos ); Geom.Vector3d axis = Geom.Vector3d.Ez * vec; double depth = 0.5 * camera.ViewingDepth; double theta = System.Math.Atan2( vec.Length, depth ); Geom.Rotation3d rot = new Geom.Rotation3d( axis.Normalize(), theta ); Geom.HmCod3d c = this.ActiveLight.Position; Geom.Vector3d d = new Geom.Vector3d( c.X, c.Y, c.Z ); d = rot.Rotate( d ); this.ActiveLight.Position = new Geom.HmCod3d( d.x, d.y, d.z, 0.0 ); viewControl.Invalidate(); _docviews.Invalidate(); } _prevPos = p; }