I'm starting to learn C # and I want to practice with vectors. I made a WPF application in which circles are created on PKM, and if you press and hold the LMB, they can be moved and when released, they should continue to move at the speed of the mouse pointer. I can't do it so that they continue to move at the right speed, it does not change. How can I find out the pointer speed? PS I tried to find out the vector by saving the previous coordinate and subtracting it from the past.

// ΠΏΡ€ΠΈ отпускании ΠΌΡ‹ΡˆΠΈ Vector mousemove = new Vector(Mouse.GetPosition(main).X - lastpos.X, Mouse.GetPosition(main).Y - lastpos.Y); elipse[i].direction = mousemove / mousemove.Length; // elipse - класс, содСрТащий ΠΊΡ€ΡƒΠ³ (Elipse) ΠΈ Π²Π΅ΠΊΡ‚ΠΎΡ€ Π΅Π³ΠΎ двиТСния (direction) //Π² Ρ‚Π°ΠΉΠΌΠ΅Ρ€Π΅ lastpos = new Point(Mouse.GetPosition(main).X, Mouse.GetPosition(main).Y); 
  • to find out the vector, it is necessary to subtract the starting from the final coordinates of the mouse. To know the speed, it is necessary to divide the distance at a time. - tym32167
  • I like it, but it doesn’t work - JernGC 2:49 pm
  • Well, give a code or an example that can be copied and run. Just the phrase "it does not work" in itself means nothing. - tym32167 3:29 pm

0