xaml - Drawing Parallel Lines in C# -


sorry if has been asked before, couldn't find valid response or response understand

currently have code draws line joint joint in kinect, forms bone:

  drawingcontext.drawline(drawpen, jointpoints[jointtype0], jointpoints[jointtype1]); 

enter image description here

in picture aboe shows parallel lines joining circle cirlce, can please explain me or show me create these lines?

if have line point p0 point p1, , want create parallel line / offset line, need use either trigonometry or vector math.

to using vector math:

  • find direction vector of line
  • find vector perpendicular that
  • use perpendicular vector offset p0 , p1

pseudo code:

vector vline = ( p1 - p0 ).normalized(); vector vperp = new vector( -vline.y, vline.x ); point newp0 = p0 + vperp * offset distance point newp1 = p1 + vperp * offset distance drawline( newp0, newp1 ); 

reverse offset or negate vperp line on other side. how depends on have available. system.windows.vector , system.windows.point should work fine since you're using wpf.

if interested in what's going on here in more detail, googling on , search vector math or linear algebra.


Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -