Skip to content
This repository has been archived by the owner on Sep 29, 2021. It is now read-only.

Commit

Permalink
Fix improper results returned for badly oriented edges.
Browse files Browse the repository at this point in the history
  • Loading branch information
tinevez committed Aug 31, 2016
1 parent 5c72765 commit 26f16af
Showing 1 changed file with 12 additions and 3 deletions.
Expand Up @@ -179,8 +179,17 @@ public void run()
DefaultWeightedEdge edge;
while ( ( edge = queue.poll() ) != null )
{
final Spot source = model.getTrackModel().getEdgeSource( edge );
final Spot target = model.getTrackModel().getEdgeTarget( edge );
Spot source = model.getTrackModel().getEdgeSource( edge );
Spot target = model.getTrackModel().getEdgeTarget( edge );

// Some edges maybe improperly oriented.
if ( source.diffTo( target, Spot.FRAME ) > 0 )
{
final Spot tmp = target;
target = source;
source = tmp;
}

/*
* Rate of directional change. We need to fetch the
* previous edge, via the source.
Expand Down Expand Up @@ -212,6 +221,7 @@ public void run()
crossProduct( dx1, dy1, dz1, dx2, dy2, dz2, out );
final double deltaAlpha = Math.atan2( norm( out ), dotProduct( dx1, dy1, dz1, dx2, dy2, dz2 ) );
final double angleSpeed = deltaAlpha / target.diffTo( source, Spot.POSITION_T );

featureModel.putEdgeFeature( edge, DIRECTIONAL_CHANGE_RATE, Double.valueOf( angleSpeed ) );
}

Expand All @@ -223,7 +233,6 @@ public void run()
SimpleMultiThreading.startAndJoin( threads );
final long end = System.currentTimeMillis();
processingTime = end - start;

}


Expand Down

0 comments on commit 26f16af

Please sign in to comment.