signature:
public class ClassLoaderResourceNotificationService { /** * Implementation */
private NotificationResponse fetchFromClasspath ( List < String > locations ) { } }

implementation:
if ( locations . isEmpty ( ) ) { return NotificationResponse . EMPTY_RESPONSE ; } NotificationResponse rslt ; final Element m = cache . get ( locations ) ; if ( m != null ) { // # # CACHE HIT # #
rslt = ( NotificationResponse ) m . getObjectValue ( ) ; logger . debug ( "Locations cache HIT for collection {};  size={}" , locations , rslt . size ( ) ) ; } else { // # # CACHE MISS # #
rslt = new NotificationResponse ( ) ; for ( String loc : locations ) { final NotificationResponse response = readFromFile ( loc ) ; rslt = rslt . combine ( response ) ; } logger . debug ( "Locations cache MISS for collection {};  size={}" , locations , rslt . size ( ) ) ; cache . put ( new Element ( locations , rslt ) ) ; } return rslt ;


signature:
public class ClassLoaderResourceNotificationService { /** * Deserialize the given JSON formatted file back into a object .
 * @ param filename The path and name of the file to be read .
 * @ return NotificationRequest , null if the de - serialization fails . */
private NotificationResponse readFromFile ( String filename ) { } }

implementation: NotificationResponse rslt ; logger . debug ( "Preparing to read from file:  {}" , filename ) ; URL location = getClass ( ) . getClassLoader ( ) . getResource ( filename ) ; if ( location != null ) { try { File f = new File ( location . toURI ( ) ) ; rslt = mapper . readValue ( f , NotificationResponse . class ) ; } catch ( Exception e ) { String msg = "Failed to read the data file:  " + location ; logger . error ( msg , e ) ; rslt = prepareErrorResponse ( getName ( ) , msg ) ; } } else { String msg = "Data file not found:  " + filename ; rslt = prepareErrorResponse ( getName ( ) , msg ) ; } return rslt ;


signature:
public class CacheNotificationService { /** * Implementation */
private NotificationResponse getResponseFromService ( PortletRequest req , INotificationService service ) { } }

implementation: NotificationResponse rslt ; try { rslt = service . fetch ( req ) ; } catch ( Exception e ) { final String msg = "Failed to invoke the specified service:  " + service . getName ( ) ; logger . error ( msg , e ) ; rslt = prepareErrorResponse ( getName ( ) , msg ) ; } return rslt ;


signature:
public class SSPSchoolIdPersonLookup { /** * { @ inheritDoc } */
@ Override public String lookupPersonId ( PortletRequest request ) { } }

implementation: String studentId = getSchoolId ( request ) ; if ( StringUtils . isBlank ( studentId ) ) { return null ; } Element element = cache . get ( studentId ) ; if ( element != null ) { return ( String ) element . getObjectValue ( ) ; } String url = getPersonSearchURL ( ) ; SSPApiRequest sspReq = new SSPApiRequest ( url , String . class ) . addUriParameter ( "schoolId" , studentId ) ; try { ResponseEntity < String > response = sspApi . doRequest ( sspReq ) ; String userId = extractUserId ( studentId , response ) ; Element cacheElement = new Element ( studentId , userId ) ; cache . put ( cacheElement ) ; return userId ; } catch ( Exception e ) { log . error ( e . getMessage ( ) , e ) ; return null ; }


signature:
public class SSPSchoolIdPersonLookup { /** * Get the schoolId value from the request .
 * @ param request the portlet request
 * @ return the school id . May return null if the school id is not available */
private String getSchoolId ( PortletRequest request ) { } }

implementation:
PortletPreferences prefs = request . getPreferences ( ) ; String schoolIdAttributeName = prefs . getValue ( "SSPTaskNotificationService.schoolIdAttribute" , "schoolId" ) ; Map < String , String > userInfo = ( Map < String , String > ) request . getAttribute ( PortletRequest . USER_INFO ) ; String studentId = userInfo . get ( schoolIdAttributeName ) ; if ( ! StringUtils . isEmpty ( studentId ) ) { return studentId ; } // if not found , fall back to username .
studentId = userInfo . get ( USERNAME_ATTRIBUTE ) ; return studentId ;


signature:
public class SSPSchoolIdPersonLookup { /** * Parse the person lookup response from SSP .
 * @ param studentId the uPortal studentid
 * @ param response the SSP response
 * @ return the SSP id if available , else null */
private String extractUserId ( String studentId , ResponseEntity < String > response ) { } }

implementation:
Configuration config = Configuration . builder ( ) . options ( Option . DEFAULT_PATH_LEAF_TO_NULL ) . build ( ) ; ReadContext readContext = JsonPath . using ( config ) . parse ( response . getBody ( ) ) ; String success = readContext . read ( SUCCESS_QUERY ) ; // SSP passes this as a string . . .
if ( ! "true" . equalsIgnoreCase ( success ) ) { return null ; } int count = readContext . read ( RESULTS_QUERY , Integer . class ) ; if ( count != 1 ) { // couldn ' t find a single unique result . Bail now . . .
log . warn ( "Expected a single unique result for " + studentId + ".  Found " + count ) ; return null ; } String id = readContext . read ( STUDENT_ID_QUERY ) ; return id ;


signature:
public class PortletEventNotificationService { /** * This { @ link INotificationService } is fundamentally about Java Portlets , and there is nothing
 * it can offer to this overload of < code > fetch < / code > .
 * @ since 4.0 */
@ Override public NotificationResponse fetch ( HttpServletRequest request ) { } }

implementation: logger . trace ( "{} invoked for user '{}', but there is nothing to do" , getClass ( ) . getSimpleName ( ) , usernameFinder . findUsername ( request ) ) ; return NotificationResponse . EMPTY_RESPONSE ;


signature:
public class HideAction { /** * Invoking a HideAction toggles it . */
@ Override public void invoke ( final ActionRequest req , final ActionResponse res ) throws IOException { } }

implementation:
final NotificationEntry entry = getTarget ( ) ; /* * The HideAction works like a toggle */
if ( ! isEntrySnoozed ( entry , req ) ) { // Hide it . . .
hide ( entry , req ) ; } else { // Un - hide it . . .
unhide ( entry , req ) ; }


signature:
public class HideAction { /** * / * package - private */
long calculateHideDurationMillis ( final NotificationEntry entry , final PortletRequest req ) { } }

implementation:
/* * A notification may specify it ' s own duration as an attribute ;
 * if it doesn ' t , there is a default from the ( portlet ) publication record . */
final PortletPreferences prefs = req . getPreferences ( ) ; // This is the default
String hideDurationHours = prefs . getValue ( HideNotificationServiceDecorator . HIDE_DURATION_HOURS_PREFERENCE , null ) ; // Duration specified on the entry itself will trump
final Map < String , List < String > > attributes = entry . getAttributesMap ( ) ; if ( attributes . containsKey ( HIDE_DURATION_HOURS_ATTRIBUTE_NAME ) ) { final List < String > values = attributes . get ( HIDE_DURATION_HOURS_ATTRIBUTE_NAME ) ; if ( values . size ( ) != 0 ) { hideDurationHours = values . get ( 0 ) ; // First is the only one that matters
} } final long rslt = hideDurationHours != null ? Long . parseLong ( hideDurationHours ) * MILLIS_IN_ONE_HOUR : HideNotificationServiceDecorator . HIDE_DURATION_NONE ; logger . debug ( "Calculated calculateHideDurationMillis={} for entry with id='{}', title='{}'" , rslt , entry . getId ( ) , entry . getTitle ( ) ) ; return rslt ;


signature:
public class HideAction { /** * / * package - private */
boolean isEntrySnoozed ( NotificationEntry entry , PortletRequest req ) { } }

implementation:
// An id is required for hide behavior
if ( StringUtils . isBlank ( entry . getId ( ) ) ) { return false ; } boolean rslt = false ; // default ( clearly )
final long snoozeDurationMillis = calculateHideDurationMillis ( entry , req ) ; // An entry with a negative snooze duration cannot be snoozed
if ( snoozeDurationMillis > HideNotificationServiceDecorator . HIDE_DURATION_NONE ) { final JpaServices jpaServices = ( JpaServices ) SpringContext . getApplicationContext ( ) . getBean ( "jpaServices" ) ; final List < EventDTO > history = jpaServices . getHistory ( entry , req . getRemoteUser ( ) ) ; logger . debug ( "List<EventDTO> within getNotificationsBySourceAndCustomAttribute contains {} elements" , history . size ( ) ) ; // Review the history . . .
for ( EventDTO event : history ) { switch ( event . getState ( ) ) { case SNOOZED : logger . debug ( "Found a SNOOZED event:  {}" , event ) ; // Nice , but it only counts if it isn ' t expired . . .
if ( event . getTimestamp ( ) . getTime ( ) + snoozeDurationMillis > System . currentTimeMillis ( ) ) { rslt = true ; } break ; case ISSUED : logger . debug ( "Found an ISSUED event:  {}" , event ) ; // Re - issuing a notification un - snoozes it . . .
rslt = false ; break ; default : // We don ' t care about any other events in the SNOOZED evaluation . . .
break ; } } } logger . debug ( "Returning SNOOZED='{}' for the following notification:  {}" , rslt , entry ) ; return rslt ;


signature:
public class HideAction { /** * Implementation */
private void hide ( NotificationEntry entry , ActionRequest req ) { } }

implementation: final JpaServices jpaServices = ( JpaServices ) SpringContext . getApplicationContext ( ) . getBean ( "jpaServices" ) ; jpaServices . applyState ( entry , req . getRemoteUser ( ) , NotificationState . SNOOZED ) ;


signature:
public class NotificationEntry { /** * Convenience method for obtaining the attributes in a more usable collection . */
@ JsonIgnore public Map < String , List < String > > getAttributesMap ( ) { } }

implementation: Map < String , List < String > > rslt = new HashMap < > ( ) ; for ( NotificationAttribute a : attributes ) { rslt . put ( a . getName ( ) , a . getValues ( ) ) ; } return rslt ;


signature:
public class UtilTrig_F64 { /** * Normalizes the point such that the Frobenius norm is 1.
 * @ param p */
public static void normalize ( GeoTuple3D_F64 p ) { } }

implementation: double n = p . norm ( ) ; p . x /= n ; p . y /= n ; p . z /= n ;


signature:
public class Intersection3D_I32 { /** * Returns true if the point is contained inside the box . The point is considered to be inside the box
 * if the following test passes for each dimension . box . p0 . x & le ; point . x { @ code < } box . p1 . x + box . lengthX
 * @ param box Box
 * @ param point Point which is tested to see if it is inside the box
 * @ return true for inside and false for not */
public static boolean contained ( Box3D_I32 box , Point3D_I32 point ) { } }

implementation: return ( box . p0 . x <= point . x && point . x < box . p1 . x && box . p0 . y <= point . y && point . y < box . p1 . y && box . p0 . z <= point . z && point . z < box . p1 . z ) ;


signature:
public class Intersection3D_I32 { /** * Returns true if boxB is contained inside of or is identical to boxA .
 * @ param boxA Box
 * @ param boxB Box which is being tested to see if it is inside of boxA
 * @ return true if inside / identical or false if outside */
public static boolean contained ( Box3D_I32 boxA , Box3D_I32 boxB ) { } }

implementation: return ( boxA . p0 . x <= boxB . p0 . x && boxA . p1 . x >= boxB . p1 . x && boxA . p0 . y <= boxB . p0 . y && boxA . p1 . y >= boxB . p1 . y && boxA . p0 . z <= boxB . p0 . z && boxA . p1 . z >= boxB . p1 . z ) ;


signature:
public class DistancePointTriangle3D_F64 { /** * Find the closest point on the triangle to P .
 * @ param P Input . The point for which the closest point is to be found .
 * @ param closestPt Output . The found closest point . */
public void closestPoint ( Point3D_F64 P , Point3D_F64 closestPt ) { } }

implementation:
// D = B - P
GeometryMath_F64 . sub ( B , P , D ) ; a = E0 . dot ( E0 ) ; b = E0 . dot ( E1 ) ; c = E1 . dot ( E1 ) ; d = E0 . dot ( D ) ; e = E1 . dot ( D ) ; double det = a * c - b * b ; s = b * e - c * d ; t = b * d - a * e ; if ( s + t <= det ) { if ( s < 0 ) { if ( t < 0 ) { region4 ( ) ; } else { region3 ( ) ; } } else if ( t < 0 ) { region5 ( ) ; } else { region0 ( det ) ; } } else { if ( s < 0 ) { region2 ( ) ; } else if ( t < 0 ) { region6 ( ) ; } else { region1 ( ) ; } } closestPt . x = B . x + s * E0 . x + t * E1 . x ; closestPt . y = B . y + s * E0 . y + t * E1 . y ; closestPt . z = B . z + s * E0 . z + t * E1 . z ;


signature:
public class DistancePointTriangle3D_F64 { /** * Returns the signed of the vector . If its " in front " it will be positive and negative if " behind " . In front
 * is defined as being on the same side as the cross product of p2 - p0 and p1 - p0.
 * @ param P Point for which the sign is determined */
public double sign ( Point3D_F64 P ) { } }

implementation:
GeometryMath_F64 . cross ( E1 , E0 , N ) ; // dot product of
double d = N . x * ( P . x - B . x ) + N . y * ( P . y - B . y ) + N . z * ( P . z - B . z ) ; return Math . signum ( d ) ;


signature:
public class Se3_F64 { /** * Set ' s ' this ' Se3 _ F64 to be identical to the provided transform .
 * @ param se The transform that is being copied . */
public void set ( Se3_F64 se ) { } }

implementation: R . set ( se . getR ( ) ) ; T . set ( se . getT ( ) ) ;


signature:
public class Se3_F64 { /** * Fully specify the transform using Euler angles */
public void set ( double x , double y , double z , EulerType type , double rotA , double rotB , double rotC ) { } }

implementation: T . set ( x , y , z ) ; ConvertRotation3D_F64 . eulerToMatrix ( type , rotA , rotB , rotC , R ) ;


signature:
public class Se3_F64 { /** * Fully specifies the transform using Rodrigues ( axis angle ) or Quaternions . If Rodrigues then A = axisX , B = axisY ,
 * C = axisZ , D = theta . If Quaternion then A = w , B = x , C = y , D = z . */
public void set ( double x , double y , double z , RotationType type , double A , double B , double C , double D ) { } }

implementation: T . set ( x , y , z ) ; switch ( type ) { case RODRIGUES : ConvertRotation3D_F64 . rodriguesToMatrix ( A , B , C , D , R ) ; break ; case QUATERNION : ConvertRotation3D_F64 . quaternionToMatrix ( A , B , C , D , R ) ; break ; default : throw new IllegalArgumentException ( "Type is not supported. " + type ) ; }


signature:
public class Se3_F64 { /** * Applies the transform to the src point and stores the result in dst . src and dst can be the same instance
 * @ see SePointOps _ F64 # transform ( Se3 _ F64 , Point3D _ F64 , Point3D _ F64)
 * @ param src Input
 * @ param dst Output
 * @ return Output */
public Point3D_F64 transform ( Point3D_F64 src , @ Nullable Point3D_F64 dst ) { } }

implementation: return SePointOps_F64 . transform ( this , src , dst ) ;


signature:
public class Se3_F64 { /** * Applies the reverse transform to the src point and stores the result in dst . src and dst can be the same instance
 * @ see SePointOps _ F64 # transformReverse ( Se3 _ F64 , Point3D _ F64 , Point3D _ F64)
 * @ param src Input
 * @ param dst Output
 * @ return Output */
public Point3D_F64 transformReverse ( Point3D_F64 src , @ Nullable Point3D_F64 dst ) { } }

implementation: return SePointOps_F64 . transformReverse ( this , src , dst ) ;


signature:
public class Se3_F64 { /** * Applies the rotation to the src vector and stores the result in dst . src and dst can be the same instance
 * @ see GeometryMath _ F64 # mult ( DMatrixRMaj , GeoTuple2D _ F64 , GeoTuple2D _ F64)
 * @ param src Input
 * @ param dst Output */
public Vector3D_F64 transform ( Vector3D_F64 src , @ Nullable Vector3D_F64 dst ) { } }

implementation: return GeometryMath_F64 . mult ( R , src , dst ) ;


signature:
public class Se3_F64 { /** * Applies the reverse rotation to the src vector and stores the result in dst . src and dst can be the same instance
 * @ see GeometryMath _ F64 # multTran ( DMatrixRMaj , GeoTuple3D _ F64 , GeoTuple3D _ F64)
 * @ param src Input
 * @ param dst Output */
public Vector3D_F64 transformReverse ( Vector3D_F64 src , @ Nullable Vector3D_F64 dst ) { } }

implementation: return GeometryMath_F64 . multTran ( R , src , dst ) ;


signature:
public class UtilPolygons2D_F64 { /** * Converts a rectangle into a quadrilateral
 * @ param input Rectangle .
 * @ param output Quadrilateral . Modified . */
public static void convert ( Rectangle2D_F64 input , Quadrilateral_F64 output ) { } }

implementation: output . a . x = input . p0 . x ; output . a . y = input . p0 . y ; output . b . x = input . p1 . x ; output . b . y = input . p0 . y ; output . c . x = input . p1 . x ; output . c . y = input . p1 . y ; output . d . x = input . p0 . x ; output . d . y = input . p1 . y ;


signature:
public class UtilPolygons2D_F64 { /** * Converts a rectangle into a polygon
 * @ param input Rectangle .
 * @ param output Polygon2D _ F64 . Modified . */
public static void convert ( Rectangle2D_F64 input , Polygon2D_F64 output ) { } }

implementation: if ( output . size ( ) != 4 ) throw new IllegalArgumentException ( "polygon of order 4 expected" ) ; output . get ( 0 ) . set ( input . p0 . x , input . p0 . y ) ; output . get ( 1 ) . set ( input . p1 . x , input . p0 . y ) ; output . get ( 2 ) . set ( input . p1 . x , input . p1 . y ) ; output . get ( 3 ) . set ( input . p0 . x , input . p1 . y ) ;


signature:
public class UtilPolygons2D_F64 { /** * Converts a polygon into a quadrilateral
 * @ param input polygon .
 * @ param output Quadrilateral . Modified . */
public static void convert ( Polygon2D_F64 input , Quadrilateral_F64 output ) { } }

implementation: if ( input . size ( ) != 4 ) throw new IllegalArgumentException ( "Expected 4-sided polygon as input" ) ; output . a . set ( input . get ( 0 ) ) ; output . b . set ( input . get ( 1 ) ) ; output . c . set ( input . get ( 2 ) ) ; output . d . set ( input . get ( 3 ) ) ;


signature:
public class UtilPolygons2D_F64 { /** * Converts a rectangle into a quadrilateral
 * @ param input Rectangle .
 * @ param output Quadrilateral . Modified . */
public static void convert ( RectangleLength2D_I32 input , Quadrilateral_F64 output ) { } }

implementation: output . a . x = input . x0 ; output . a . y = input . y0 ; output . b . x = input . x0 + input . width - 1 ; output . b . y = input . y0 ; output . c . x = input . x0 + input . width - 1 ; output . c . y = input . y0 + input . height - 1 ; output . d . x = input . x0 ; output . d . y = input . y0 + input . height - 1 ;


signature:
public class UtilPolygons2D_F64 { /** * Finds the minimum area bounding rectangle around the quadrilateral .
 * @ param quad ( Input ) Quadrilateral
 * @ param rectangle ( Output ) Minimum area rectangle */
public static void bounding ( Quadrilateral_F64 quad , Rectangle2D_F64 rectangle ) { } }

implementation: rectangle . p0 . x = Math . min ( quad . a . x , quad . b . x ) ; rectangle . p0 . x = Math . min ( rectangle . p0 . x , quad . c . x ) ; rectangle . p0 . x = Math . min ( rectangle . p0 . x , quad . d . x ) ; rectangle . p0 . y = Math . min ( quad . a . y , quad . b . y ) ; rectangle . p0 . y = Math . min ( rectangle . p0 . y , quad . c . y ) ; rectangle . p0 . y = Math . min ( rectangle . p0 . y , quad . d . y ) ; rectangle . p1 . x = Math . max ( quad . a . x , quad . b . x ) ; rectangle . p1 . x = Math . max ( rectangle . p1 . x , quad . c . x ) ; rectangle . p1 . x = Math . max ( rectangle . p1 . x , quad . d . x ) ; rectangle . p1 . y = Math . max ( quad . a . y , quad . b . y ) ; rectangle . p1 . y = Math . max ( rectangle . p1 . y , quad . c . y ) ; rectangle . p1 . y = Math . max ( rectangle . p1 . y , quad . d . y ) ;


signature:
public class UtilPolygons2D_F64 { /** * Finds the minimum area bounding rectangle around the quadrilateral that is aligned with coordinate
 * system axises .
 * @ param polygon ( Input ) Polygon
 * @ param rectangle ( Output ) Minimum area rectangle */
public static void bounding ( Polygon2D_F64 polygon , Rectangle2D_F64 rectangle ) { } }

implementation: rectangle . p0 . set ( polygon . get ( 0 ) ) ; rectangle . p1 . set ( polygon . get ( 0 ) ) ; for ( int i = 0 ; i < polygon . size ( ) ; i ++ ) { Point2D_F64 p = polygon . get ( i ) ; if ( p . x < rectangle . p0 . x ) { rectangle . p0 . x = p . x ; } else if ( p . x > rectangle . p1 . x ) { rectangle . p1 . x = p . x ; } if ( p . y < rectangle . p0 . y ) { rectangle . p0 . y = p . y ; } else if ( p . y > rectangle . p1 . y ) { rectangle . p1 . y = p . y ; } }


signature:
public class UtilPolygons2D_F64 { /** * Computes the center or average point in the quadrilateral .
 * @ param quad ( Input ) Quadrilateral
 * @ param center ( output ) Center point of the quadrilateral . Can be null .
 * @ return The center point . */
public static Point2D_F64 center ( Quadrilateral_F64 quad , Point2D_F64 center ) { } }

implementation: if ( center == null ) center = new Point2D_F64 ( ) ; center . x = quad . a . x + quad . b . x + quad . c . x + quad . d . x ; center . y = quad . a . y + quad . b . y + quad . c . y + quad . d . y ; center . x /= 4.0 ; center . y /= 4.0 ; return center ;


signature:
public class UtilPolygons2D_F64 { /** * Returns true if the polygon is ordered in a counter - clockwise order . This is done by summing up the interior
 * angles .
 * @ param polygon List of ordered points which define a polygon
 * @ return true if CCW and false if CW */
public static boolean isCCW ( List < Point2D_F64 > polygon ) { } }

implementation: final int N = polygon . size ( ) ; int sign = 0 ; for ( int i = 0 ; i < N ; i ++ ) { int j = ( i + 1 ) % N ; int k = ( i + 2 ) % N ; Point2D_F64 a = polygon . get ( i ) ; Point2D_F64 b = polygon . get ( j ) ; Point2D_F64 c = polygon . get ( k ) ; double dx0 = a . x - b . x ; double dy0 = a . y - b . y ; double dx1 = c . x - b . x ; double dy1 = c . y - b . y ; double z = dx0 * dy1 - dy0 * dx1 ; if ( z > 0 ) sign ++ ; else sign -- ; } return sign < 0 ;


signature:
public class UtilPolygons2D_F64 { /** * Computes the average of all the vertexes
 * @ param input ( input ) polygon
 * @ param average ( output ) average point */
public static void vertexAverage ( Polygon2D_F64 input , Point2D_F64 average ) { } }

implementation: average . setIdx ( 0 , 0 ) ; for ( int i = 0 ; i < input . size ( ) ; i ++ ) { Point2D_F64 v = input . vertexes . data [ i ] ; average . x += v . x ; average . y += v . y ; } average . x /= input . size ( ) ; average . y /= input . size ( ) ;


signature:
public class UtilPolygons2D_F64 { /** * Checks to see if the vertexes of the two polygon ' s are the same up to the specified tolerance
 * @ param a Polygon
 * @ param b Polygon
 * @ param tol tolerance
 * @ return true if identical up to tolerance or false if not */
public static boolean isIdentical ( Polygon2D_F64 a , Polygon2D_F64 b , double tol ) { } }

implementation: if ( a . size ( ) != b . size ( ) ) return false ; double tol2 = tol * tol ; for ( int i = 0 ; i < a . size ( ) ; i ++ ) { if ( a . get ( i ) . distance2 ( b . get ( i ) ) > tol2 ) return false ; } return true ;


signature:
public class UtilPolygons2D_F64 { /** * Checks to see if the vertexes of the two polygon ' s are the same up to the specified tolerance and allows
 * for a shift in their order
 * @ param a Polygon
 * @ param b Polygon
 * @ param tol tolerance
 * @ return true if identical up to tolerance or false if not */
public static boolean isEquivalent ( Polygon2D_F64 a , Polygon2D_F64 b , double tol ) { } }

implementation:
if ( a . size ( ) != b . size ( ) ) return false ; double tol2 = tol * tol ; // first find two vertexes which are the same
Point2D_F64 a0 = a . get ( 0 ) ; int match = - 1 ; for ( int i = 0 ; i < b . size ( ) ; i ++ ) { if ( a0 . distance2 ( b . get ( i ) ) <= tol2 ) { match = i ; break ; } } if ( match < 0 ) return false ; // now go in a circle and see if they all line up
for ( int i = 1 ; i < b . size ( ) ; i ++ ) { Point2D_F64 ai = a . get ( i ) ; Point2D_F64 bi = b . get ( ( match + i ) % b . size ( ) ) ; if ( ai . distance2 ( bi ) > tol2 ) { return false ; } } return true ;


signature:
public class UtilPolygons2D_F64 { /** * Flips the order of points inside the polygon . The first index will remain the same will otherwise be reversed
 * @ param a Polygon of order 3 or more . */
public static void flip ( Polygon2D_F64 a ) { } }

implementation: int N = a . size ( ) ; int H = N / 2 ; for ( int i = 1 ; i <= H ; i ++ ) { int j = N - i ; Point2D_F64 tmp = a . vertexes . data [ i ] ; a . vertexes . data [ i ] = a . vertexes . data [ j ] ; a . vertexes . data [ j ] = tmp ; }


signature:
public class UtilPolygons2D_F64 { /** * Shifts all the vertexes in the polygon up one element . Wraps around at the end
 * @ param a Polygon */
public static void shiftUp ( Polygon2D_F64 a ) { } }

implementation: final int N = a . size ( ) ; Point2D_F64 first = a . get ( 0 ) ; for ( int i = 0 ; i < N - 1 ; i ++ ) { a . vertexes . data [ i ] = a . vertexes . data [ i + 1 ] ; } a . vertexes . data [ N - 1 ] = first ;


signature:
public class UtilPolygons2D_F64 { /** * Shifts all the vertexes in the polygon up one element . Wraps around at the end
 * @ param a Polygon */
public static void shiftDown ( Polygon2D_F64 a ) { } }

implementation: final int N = a . size ( ) ; Point2D_F64 last = a . get ( N - 1 ) ; for ( int i = N - 1 ; i > 0 ; i -- ) { a . vertexes . data [ i ] = a . vertexes . data [ i - 1 ] ; } a . vertexes . data [ 0 ] = last ;


signature:
public class UtilPolygons2D_F64 { /** * Computes the convex hull of the set of points .
 * NOTE : This method declares a temporary array . If you want to avoid that invoke { @ link AndrewMonotoneConvexHull _ F64}
 * directly .
 * @ param points ( Input ) Set of points .
 * @ param hull ( output ) storage for convex hull . Will be in counter - clockwise order */
public static void convexHull ( List < Point2D_F64 > points , Polygon2D_F64 hull ) { } }

implementation: Point2D_F64 [ ] array = new Point2D_F64 [ points . size ( ) ] ; for ( int i = 0 ; i < points . size ( ) ; i ++ ) { array [ i ] = points . get ( i ) ; } AndrewMonotoneConvexHull_F64 andrew = new AndrewMonotoneConvexHull_F64 ( ) ; andrew . process ( array , array . length , hull ) ;


signature:
public class UtilPolygons2D_F64 { /** * Removes a node from a polygon if the two lines its attached two are almost parallel
 * @ param polygon The polygon being modified
 * @ param tol Tolerance in radians */
public static void removeAlmostParallel ( Polygon2D_F64 polygon , double tol ) { } }

implementation: for ( int i = 0 ; i < polygon . vertexes . size ( ) ; ) { int j = ( i + 1 ) % polygon . vertexes . size ( ) ; int k = ( i + 2 ) % polygon . vertexes . size ( ) ; Point2D_F64 p0 = polygon . vertexes . get ( i ) ; Point2D_F64 p1 = polygon . vertexes . get ( j ) ; Point2D_F64 p2 = polygon . vertexes . get ( k ) ; double angle = UtilVector2D_F64 . acute ( p1 . x - p0 . x , p1 . y - p0 . y , p2 . x - p1 . x , p2 . y - p1 . y ) ; if ( angle <= tol ) { polygon . vertexes . remove ( j ) ; if ( j < i ) i = polygon . vertexes . size ( ) - 1 ; } else { i ++ ; } }


signature:
public class UtilPolygons2D_F64 { /** * Remove a point if it ' s identical to a neighbor
 * @ param polygon The polygon being modified
 * @ param tol Tolerance in radians */
public static void removeAdjacentDuplicates ( Polygon2D_F64 polygon , double tol ) { } }

implementation: for ( int i = polygon . vertexes . size ( ) - 1 , j = 0 ; i >= 0 && polygon . size ( ) > 1 ; j = i , i -- ) { if ( polygon . get ( i ) . isIdentical ( polygon . get ( j ) , tol ) ) { polygon . vertexes . remove ( i ) ; } }


signature:
public class UtilPolygons2D_F64 { /** * Remove a point if it ' s identical to a neighbor
 * @ param polygon The polygon being modified
 * @ param tol Tolerance in radians */
public static boolean hasAdjacentDuplicates ( Polygon2D_F64 polygon , double tol ) { } }

implementation: for ( int i = polygon . vertexes . size ( ) - 1 , j = 0 ; i >= 0 && polygon . size ( ) > 1 ; j = i , i -- ) { if ( polygon . get ( i ) . isIdentical ( polygon . get ( j ) , tol ) ) { return true ; } } return false ;


signature:
public class UtilPolygons2D_F64 { /** * Compute the error as a function of the distance between the model and target . The target is sampled at regular
 * intervals and for each of these points the closest point on the model is found . The returned metric is the
 * average of difference between paired points .
 * NOTE : A different answer will be returned depending on which polygon is the model and which one is the target .
 * @ param model Model polygon
 * @ param target Target polygon
 * @ return average of closest point error */
public static double averageOfClosestPointError ( Polygon2D_F64 model , Polygon2D_F64 target , int numberOfSamples ) { } }

implementation:
LineSegment2D_F64 line = new LineSegment2D_F64 ( ) ; double cornerLocationsB [ ] = new double [ target . size ( ) + 1 ] ; double totalLength = 0 ; for ( int i = 0 ; i < target . size ( ) ; i ++ ) { Point2D_F64 b0 = target . get ( i % target . size ( ) ) ; Point2D_F64 b1 = target . get ( ( i + 1 ) % target . size ( ) ) ; cornerLocationsB [ i ] = totalLength ; totalLength += b0 . distance ( b1 ) ; } cornerLocationsB [ target . size ( ) ] = totalLength ; Point2D_F64 pointOnB = new Point2D_F64 ( ) ; double error = 0 ; int cornerB = 0 ; for ( int k = 0 ; k < numberOfSamples ; k ++ ) { // Find the point on B to match to a point on A
double location = totalLength * k / numberOfSamples ; while ( location > cornerLocationsB [ cornerB + 1 ] ) { cornerB ++ ; } Point2D_F64 b0 = target . get ( cornerB ) ; Point2D_F64 b1 = target . get ( ( cornerB + 1 ) % target . size ( ) ) ; double locationCornerB = cornerLocationsB [ cornerB ] ; double fraction = ( location - locationCornerB ) / ( cornerLocationsB [ cornerB + 1 ] - locationCornerB ) ; pointOnB . x = ( b1 . x - b0 . x ) * fraction + b0 . x ; pointOnB . y = ( b1 . y - b0 . y ) * fraction + b0 . y ; // find the best fit point on A to the point in B
double best = Double . MAX_VALUE ; for ( int i = 0 ; i < model . size ( ) + 1 ; i ++ ) { line . a = model . get ( i % model . size ( ) ) ; line . b = model . get ( ( i + 1 ) % model . size ( ) ) ; double d = Distance2D_F64 . distance ( line , pointOnB ) ; if ( d < best ) { best = d ; } } error += best ; } return error / numberOfSamples ;


signature:
public class UtilHomography_F64 { /** * Converts the provided 3x3 matrix into a { @ link Homography2D _ F64 } .
 * @ param m Input 3x3 matrix .
 * @ param ret Storage for output . If null then a new instance is created .
 * @ return Equivalent homography . */
public static Homography2D_F64 convert ( DMatrixRMaj m , Homography2D_F64 ret ) { } }

implementation: if ( m . numCols != 3 || m . numRows != 3 ) throw new IllegalArgumentException ( "Expected a 3 by 3 matrix." ) ; if ( ret == null ) ret = new Homography2D_F64 ( ) ; ret . a11 = m . unsafe_get ( 0 , 0 ) ; ret . a12 = m . unsafe_get ( 0 , 1 ) ; ret . a13 = m . unsafe_get ( 0 , 2 ) ; ret . a21 = m . unsafe_get ( 1 , 0 ) ; ret . a22 = m . unsafe_get ( 1 , 1 ) ; ret . a23 = m . unsafe_get ( 1 , 2 ) ; ret . a31 = m . unsafe_get ( 2 , 0 ) ; ret . a32 = m . unsafe_get ( 2 , 1 ) ; ret . a33 = m . unsafe_get ( 2 , 2 ) ; return ret ;


signature:
public class UtilHomography_F64 { /** * Converts a { @ link Homography2D _ F64 } into a 3x3 matrix .
 * @ param m Homography
 * @ param ret Storage for output . If null then a new instance is created .
 * @ return Equivalent matrix . */
public static DMatrixRMaj convert ( Homography2D_F64 m , DMatrixRMaj ret ) { } }

implementation: if ( ret == null ) { ret = new DMatrixRMaj ( 3 , 3 ) ; } else if ( ret . numCols != 3 || ret . numRows != 3 ) throw new IllegalArgumentException ( "Expected a 3 by 3 matrix." ) ; ret . unsafe_set ( 0 , 0 , m . a11 ) ; ret . unsafe_set ( 0 , 1 , m . a12 ) ; ret . unsafe_set ( 0 , 2 , m . a13 ) ; ret . unsafe_set ( 1 , 0 , m . a21 ) ; ret . unsafe_set ( 1 , 1 , m . a22 ) ; ret . unsafe_set ( 1 , 2 , m . a23 ) ; ret . unsafe_set ( 2 , 0 , m . a31 ) ; ret . unsafe_set ( 2 , 1 , m . a32 ) ; ret . unsafe_set ( 2 , 2 , m . a33 ) ; return ret ;


signature:
public class AreaIntersectionPolygon2D_F64 { /** * Computes the area of the intersection between the two polygons .
 * Note : the area result has little more accuracy than a float
 * This is true even if the polygon is specified with doubles .
 * @ param a Polygon A
 * @ param b Polygon B
 * @ return area of area of intersection . Negative if the order ( CW vs CCW ) do not match . */
public double computeArea ( Polygon2D_F64 a , Polygon2D_F64 b ) { } }

implementation: ssss = 0 ; sclx = 0 ; scly = 0 ; return inter ( a , b ) ;


signature: public class AreaIntersectionPolygon2D_F64 { private double inter ( Polygon2D_F64 a , Polygon2D_F64 b ) { } }

implementation:
if ( a . size ( ) < 3 || b . size ( ) < 3 ) return 0 ; // int na = a . size ( ) ;
// int nb = b . size ( ) ;
Vertex [ ] ipa = new Vertex [ a . size ( ) + 1 ] ; Vertex [ ] ipb = new Vertex [ b . size ( ) + 1 ] ; Rectangle2D_F64 bbox = new Rectangle2D_F64 ( Double . MAX_VALUE , Double . MAX_VALUE , - Double . MAX_VALUE , - Double . MAX_VALUE ) ; range ( a , bbox ) ; range ( b , bbox ) ; double rngx = bbox . p1 . x - bbox . p0 . x ; sclx = gamut / rngx ; double rngy = bbox . p1 . y - bbox . p0 . y ; scly = gamut / rngy ; double ascale = sclx * scly ; fit ( a , ipa , 0 , bbox ) ; fit ( b , ipb , 2 , bbox ) ; for ( int j = 0 ; j < a . size ( ) ; ++ j ) { for ( int k = 0 ; k < b . size ( ) ; ++ k ) { if ( ovl ( ipa [ j ] . rx , ipb [ k ] . rx ) && ovl ( ipa [ j ] . ry , ipb [ k ] . ry ) ) { long a1 = - area ( ipa [ j ] . ip , ipb [ k ] . ip , ipb [ k + 1 ] . ip ) ; long a2 = area ( ipa [ j + 1 ] . ip , ipb [ k ] . ip , ipb [ k + 1 ] . ip ) ; boolean o = a1 < 0 ; if ( o == a2 < 0 ) { long a3 = area ( ipb [ k ] . ip , ipa [ j ] . ip , ipa [ j + 1 ] . ip ) ; long a4 = - area ( ipb [ k + 1 ] . ip , ipa [ j ] . ip , ipa [ j + 1 ] . ip ) ; if ( a3 < 0 == a4 < 0 ) { if ( o ) cross ( ipa [ j ] , ipa [ j + 1 ] , ipb [ k ] , ipb [ k + 1 ] , a1 , a2 , a3 , a4 ) ; else cross ( ipb [ k ] , ipb [ k + 1 ] , ipa [ j ] , ipa [ j + 1 ] , a3 , a4 , a1 , a2 ) ; } } } } } inness ( ipa , a . size ( ) , ipb , b . size ( ) ) ; inness ( ipb , b . size ( ) , ipa , a . size ( ) ) ; return ssss / ascale ;


signature:
public class LineParametric2D_I32 { /** * Returns a point along the line . See parametric equation in class description .
 * @ param t Location along the line .
 * @ return Point on the line . */
public Point2D_F64 getPointOnLine ( double t ) { } }

implementation: return new Point2D_F64 ( slopeX * t + p . x , slopeY * t + p . y ) ;


signature:
public class Intersection2D_F64 { /** * http : / / www . ecse . rpi . edu / Homepages / wrf / Research / Short _ Notes / pnpoly . html */
public static boolean containConvex ( Polygon2D_F64 polygon , Point2D_F64 pt ) { } }

implementation: final int N = polygon . size ( ) ; boolean c = false ; for ( int i = 0 , j = N - 1 ; i < N ; j = i ++ ) { Point2D_F64 a = polygon . vertexes . data [ i ] ; Point2D_F64 b = polygon . vertexes . data [ j ] ; if ( ( ( a . y > pt . y ) != ( b . y > pt . y ) ) && ( pt . x < ( b . x - a . x ) * ( pt . y - a . y ) / ( b . y - a . y ) + a . x ) ) c = ! c ; } return c ;


signature:
public class Intersection2D_F64 { /** * Checks to see if the point is contained inside the concave polygon .
 * NOTE : Points which lie along the perimeter may or may not be considered as inside
 * @ param polygon Convex polygon . Not modified .
 * @ param pt Point . Not modified .
 * @ return True if the point is contained inside the polygon . */
public static boolean containConcave ( Polygon2D_F64 polygon , Point2D_F64 pt ) { } }

implementation:
final int N = polygon . size ( ) ; int left = 0 ; int right = 0 ; for ( int i = 0 ; i < N - 1 ; i ++ ) { Point2D_F64 a = polygon . vertexes . data [ i ] ; Point2D_F64 b = polygon . vertexes . data [ i + 1 ] ; if ( ( pt . y >= a . y && pt . y < b . y ) || ( pt . y >= b . y && pt . y < a . y ) ) { // location of line segment along x - axis at y = pt . y
double x = b . y == a . y ? pt . x : ( pt . y - a . y ) * ( b . x - a . x ) / ( b . y - a . y ) + a . x ; if ( x <= pt . x ) left ++ ; else if ( x > pt . x ) right ++ ; } } Point2D_F64 a = polygon . vertexes . data [ N - 1 ] ; Point2D_F64 b = polygon . vertexes . data [ 0 ] ; if ( ( pt . y >= a . y && pt . y < b . y ) || ( pt . y >= b . y && pt . y < a . y ) ) { // location of line segment along x - axis at y = pt . y
double x = b . y == a . y ? pt . x : ( pt . y - pt . y ) * ( b . x - a . x ) / ( b . y - a . y ) + a . x ; if ( x <= pt . x ) left ++ ; else if ( x > pt . x ) right ++ ; } return ( left % 2 == 1 && right % 2 == 1 ) ;


signature:
public class Intersection2D_F64 { /** * True if the point is contained inside the quadrilateral .
 * @ param quad quadrilateral
 * @ param pt point
 * @ return true if the point is inside and false if it is not . */
public static boolean contains ( Quadrilateral_F64 quad , Point2D_F64 pt ) { } }

implementation: return containTriangle ( quad . a , quad . b , quad . d , pt ) || containTriangle ( quad . b , quad . c , quad . d , pt ) ;


signature:
public class Intersection2D_F64 { /** * Returns true of the the point is inside the triangle .
 * This function is simply an unrolled version of { @ link # containConcave ( Polygon2D _ F64 , Point2D _ F64 ) } .
 * @ param a vertex in triangle
 * @ param b vertex in triangle
 * @ param c vertex in triangle
 * @ param pt Point which is being tested for containment inside of triangle
 * @ return true if the point is inside of triangle */
public static boolean containTriangle ( Point2D_F64 a , Point2D_F64 b , Point2D_F64 c , Point2D_F64 pt ) { } }


signature:
public class Intersection2D_F64 { /** * Finds the point of intersection between two lines and returns the point .
 * @ param a Line .
 * @ param b Line .
 * @ param ret storage for the point of intersection . If null a new point will be declared .
 * @ return If the two lines intersect it returns the point of intersection . null if they don ' t intersect or have infinite intersections . */
public static Point2D_F64 intersection ( LineParametric2D_F64 a , LineParametric2D_F64 b , Point2D_F64 ret ) { } }

implementation: double t_b = a . getSlopeX ( ) * ( b . getY ( ) - a . getY ( ) ) - a . getSlopeY ( ) * ( b . getX ( ) - a . getX ( ) ) ; double bottom = a . getSlopeY ( ) * b . getSlopeX ( ) - b . getSlopeY ( ) * a . getSlopeX ( ) ; if ( bottom == 0 ) return null ; t_b /= bottom ; double x = b . getSlopeX ( ) * t_b + b . getX ( ) ; double y = b . getSlopeY ( ) * t_b + b . getY ( ) ; if ( ret == null ) ret = new Point2D_F64 ( ) ; ret . set ( x , y ) ; return ret ;


signature:
public class Intersection2D_F64 { /** * Finds the point of intersection between two lines . The point of intersection is specified as a point along
 * the parametric line ' a ' . ( x , y ) = ( x _ 0 , y _ 0 ) + t * ( slope _ x , slope _ y ) , where ' t ' is the location returned .
 * @ param a Line .
 * @ param b Line .
 * @ return The location along ' target ' . If the lines do not intersect or have infinite intersections Double . NaN is returned . */
public static double intersection ( LineParametric2D_F64 a , LineParametric2D_F64 b ) { } }

implementation: double t_a = b . getSlopeX ( ) * ( a . getY ( ) - b . getY ( ) ) - b . getSlopeY ( ) * ( a . getX ( ) - b . getX ( ) ) ; double bottom = b . getSlopeY ( ) * a . getSlopeX ( ) - a . getSlopeY ( ) * b . getSlopeX ( ) ; if ( bottom == 0 ) return Double . NaN ; return t_a / bottom ;


signature:
public class Intersection2D_F64 { /** * Finds the point of intersection between two lines segments .
 * @ param l _ 0 Line segment .
 * @ param l _ 1 line segment .
 * @ param ret storage for the point of intersection . If null a new point will be declared .
 * @ return If the two lines intersect it returns the point of intersection . null if they don ' t intersect or have infinite intersections . */
public static Point2D_F64 intersection ( LineSegment2D_F64 l_0 , LineSegment2D_F64 l_1 , Point2D_F64 ret ) { } }

implementation:
double a0 = l_0 . b . x - l_0 . a . x ; double b0 = l_0 . b . y - l_0 . a . y ; double a1 = l_1 . b . x - l_1 . a . x ; double b1 = l_1 . b . y - l_1 . a . y ; double top = b0 * ( l_1 . a . x - l_0 . a . x ) + a0 * ( l_0 . a . y - l_1 . a . y ) ; double bottom = a0 * b1 - b0 * a1 ; if ( bottom == 0 ) return null ; double t_1 = top / bottom ; // does not intersect along the second line segment
if ( t_1 < 0 || t_1 > 1 ) return null ; top = b1 * ( l_0 . a . x - l_1 . a . x ) + a1 * ( l_1 . a . y - l_0 . a . y ) ; bottom = a1 * b0 - b1 * a0 ; double t_0 = top / bottom ; // does not intersect along the first line segment
if ( t_0 < 0 || t_0 > 1 ) return null ; if ( ret == null ) { ret = new Point2D_F64 ( ) ; } ret . set ( l_1 . a . x + a1 * t_1 , l_1 . a . y + b1 * t_1 ) ; return ret ;


signature:
public class Intersection2D_F64 { /** * Finds the intersection of two lines as a 2D point in homogeneous coordinates . Because the
 * solution is found in homogeneous coordinates it can even handle parallel lines which " intersect
 * at infinity " .
 * A 2D point in homogeneous coordinates is expressed as the triple ( x , y , z ) , which can be converted
 * into the standard notation as x ' = x / z and y ' = y / z . If the lines are parallel and intersect at
 * infinity then z = 0 and the above conversion will fail .
 * @ param a Line
 * @ param b Line
 * @ param ret Storage for point of intersection .
 * @ return Point of intersection represented in homogeneous coordinates . */
public static Point3D_F64 intersection ( LineGeneral2D_F64 a , LineGeneral2D_F64 b , Point3D_F64 ret ) { } }

implementation:
if ( ret == null ) ret = new Point3D_F64 ( ) ; // compute the intersection as the cross product of ' a ' and ' b '
ret . x = a . B * b . C - a . C * b . B ; ret . y = a . C * b . A - a . A * b . C ; ret . z = a . A * b . B - a . B * b . A ; return ret ;


signature:
public class Intersection2D_F64 { /** * Finds the point of intersection between the two lines defined by the set sets of points passed in .
 * @ param lineA0 Point on line A
 * @ param lineA1 Point on line A
 * @ param lineB0 Point on line B
 * @ param lineB1 Point on line B
 * @ param output ( Optional ) storage for point of intersection
 * @ return Point of intersection or null if the lines are parallel */
public static Point2D_F64 intersection ( Point2D_F64 lineA0 , Point2D_F64 lineA1 , Point2D_F64 lineB0 , Point2D_F64 lineB1 , Point2D_F64 output ) { } }

implementation: if ( output == null ) output = new Point2D_F64 ( ) ; double slopeAx = lineA1 . x - lineA0 . x ; double slopeAy = lineA1 . y - lineA0 . y ; double slopeBx = lineB1 . x - lineB0 . x ; double slopeBy = lineB1 . y - lineB0 . y ; double top = slopeAy * ( lineB0 . x - lineA0 . x ) + slopeAx * ( lineA0 . y - lineB0 . y ) ; double bottom = slopeAx * slopeBy - slopeAy * slopeBx ; if ( bottom == 0 ) return null ; double t = top / bottom ; output . x = lineB0 . x + t * slopeBx ; output . y = lineB0 . y + t * slopeBy ; return output ;


signature:
public class Intersection2D_F64 { /** * Finds the point of intersection between a line and a line segment . The point of intersection
 * is specified as the distance along the parametric line . If no intersection is found then
 * Double . NaN is returned .
 * @ param target A line whose location along which the point of intersection is being found . Not modified .
 * @ param l Line segment which is being tested for intersection . Not modified .
 * @ return The location along ' target ' . If the lines do not intersect or have infinite intersections Double . NaN is returned . */
public static double intersection ( LineParametric2D_F64 target , LineSegment2D_F64 l ) { } }

implementation:
double a1 = l . b . x - l . a . x ; double b1 = l . b . y - l . a . y ; double top = target . slope . y * ( l . a . x - target . p . x ) + target . slope . x * ( target . p . y - l . a . y ) ; double bottom = target . slope . x * b1 - target . slope . y * a1 ; if ( bottom == 0 ) return Double . NaN ; double t_1 = top / bottom ; // does not intersect along the second line segment
if ( t_1 < 0 || t_1 > 1 ) return Double . NaN ; top = b1 * ( target . p . x - l . a . x ) + a1 * ( l . a . y - target . p . y ) ; bottom = a1 * target . slope . y - b1 * target . slope . x ; return top / bottom ;


signature:
public class Intersection2D_F64 { /** * Finds the area of the intersection of two polygons .
 * @ see AreaIntersectionPolygon2D _ F64
 * @ param a ( Input ) Polygon 2D
 * @ param b ( Input ) Polygon 2D
 * @ return Area of intersection . */
public static double intersection ( Polygon2D_F64 a , Polygon2D_F64 b ) { } }

implementation: AreaIntersectionPolygon2D_F64 alg = new AreaIntersectionPolygon2D_F64 ( ) ; return Math . abs ( alg . computeArea ( a , b ) ) ;


signature:
public class Intersection2D_F64 { /** * Checks to see if the specified point is inside the rectangle . A point is inside
 * if it is & ge ; the lower extend and & lt ; the upper extent .
 * inside = x & ge ; x0 AND x & le ; x1 AND y & ge ; y0 AND y & le ; y1
 * @ param a Rectangle .
 * @ param x x - coordinate of point being tested for containment
 * @ param y y - coordinate of point being tested for containment
 * @ return true if inside and false if output */
public static boolean contains ( Rectangle2D_F64 a , double x , double y ) { } }


signature:
public class Intersection2D_F64 { /** * Checks to see if the specified point is inside the rectangle . A point is inside
 * if it is & ge ; the lower extend and & le ; the upper extent .
 * inside = x & ge ; x0 AND x & le ; x1 AND y & ge ; y0 AND y & le ; y1
 * @ param a Rectangle .
 * @ param x x - coordinate of point being tested for containment
 * @ param y y - coordinate of point being tested for containment
 * @ return true if inside and false if output */
public static boolean contains2 ( Rectangle2D_F64 a , double x , double y ) { } }


signature:
public class Intersection2D_F64 { /** * Tests to see if the provided point lies on or is contained inside the ellipse
 * @ param ellipse Ellipse
 * @ param x x - coordinate of point being tested for containment
 * @ param y y - coordinate of point being tested for containment
 * @ return true if inside and false if output */
public static boolean contains ( EllipseRotated_F64 ellipse , double x , double y ) { } }

implementation: return ( UtilEllipse_F64 . evaluate ( x , y , ellipse ) <= 1.0 ) ;


signature:
public class Intersection2D_F64 { /** * Checks to see if the two rectangles intersect each other
 * @ param a Rectangle
 * @ param b Rectangle
 * @ return true if intersection */
public static boolean intersects ( Rectangle2D_F64 a , Rectangle2D_F64 b ) { } }


signature:
public class Intersection2D_F64 { /** * Finds the intersection between two rectangles . If the rectangles don ' t intersect then false is returned .
 * @ param a Rectangle
 * @ param b Rectangle
 * @ param result Storage for the found intersection
 * @ return true if intersection */
public static boolean intersection ( Rectangle2D_F64 a , Rectangle2D_F64 b , Rectangle2D_F64 result ) { } }

implementation: if ( ! intersects ( a , b ) ) return false ; result . p0 . x = Math . max ( a . p0 . x , b . p0 . x ) ; result . p1 . x = Math . min ( a . p1 . x , b . p1 . x ) ; result . p0 . y = Math . max ( a . p0 . y , b . p0 . y ) ; result . p1 . y = Math . min ( a . p1 . y , b . p1 . y ) ; return true ;


signature:
public class Intersection2D_F64 { /** * Returns the area of the intersection of two rectangles .
 * @ param a Rectangle
 * @ param b Rectangle
 * @ return area of intersection */
public static double intersectionArea ( Rectangle2D_F64 a , Rectangle2D_F64 b ) { } }

implementation: if ( ! intersects ( a , b ) ) return 0 ; double x0 = Math . max ( a . p0 . x , b . p0 . x ) ; double x1 = Math . min ( a . p1 . x , b . p1 . x ) ; double y0 = Math . max ( a . p0 . y , b . p0 . y ) ; double y1 = Math . min ( a . p1 . y , b . p1 . y ) ; return ( x1 - x0 ) * ( y1 - y0 ) ;


signature:
public class Intersection2D_F64 { /** * Determines the location ( s ) that a line and ellipse intersect . Returns the number of intersections found .
 * NOTE : Due to floating point errors , it ' s possible for a single solution to returned as two points .
 * @ param line Line
 * @ param ellipse Ellipse
 * @ param intersection0 Storage for first point of intersection .
 * @ param intersection1 Storage for second point of intersection .
 * @ param EPS Numerical precision . Set to a negative value to use default
 * @ return Number of intersections . Possible values are 0 , 1 , or 2. */
public static int intersection ( LineGeneral2D_F64 line , EllipseRotated_F64 ellipse , Point2D_F64 intersection0 , Point2D_F64 intersection1 , double EPS ) { } }

implementation:
if ( EPS < 0 ) { EPS = GrlConstants . EPS ; } // First translate the line so that coordinate origin is the same as the ellipse
double C = line . C + ( line . A * ellipse . center . x + line . B * ellipse . center . y ) ; // Now rotate the line
double cphi = Math . cos ( ellipse . phi ) ; double sphi = Math . sin ( ellipse . phi ) ; double A = line . A * cphi + line . B * sphi ; double B = - line . A * sphi + line . B * cphi ; // Now solve for the intersections with the coordinate system centered and aligned to the ellipse
// There are two different ways to solve for this . Pick the axis with the largest slope
// to avoid the pathological case
double a2 = ellipse . a * ellipse . a ; double b2 = ellipse . b * ellipse . b ; double x0 , y0 ; double x1 , y1 ; int totalIntersections ; if ( Math . abs ( A ) > Math . abs ( B ) ) { double alpha = - C / A ; double beta = - B / A ; double aa = beta * beta / a2 + 1.0 / b2 ; double bb = 2.0 * alpha * beta / a2 ; double cc = alpha * alpha / a2 - 1.0 ; double inner = bb * bb - 4.0 * aa * cc ; if ( Math . abs ( inner / aa ) < EPS ) { // divide by aa for scale invariance
totalIntersections = 1 ; inner = inner < 0 ? 0 : inner ; } else if ( inner < 0 ) { return 0 ; } else { totalIntersections = 2 ; } double right = Math . sqrt ( inner ) ; y0 = ( - bb + right ) / ( 2.0 * aa ) ; y1 = ( - bb - right ) / ( 2.0 * aa ) ; x0 = - ( C + B * y0 ) / A ; x1 = - ( C + B * y1 ) / A ; } else { double alpha = - C / B ; double beta = - A / B ; double aa = beta * beta / b2 + 1.0 / a2 ; double bb = 2.0 * alpha * beta / b2 ; double cc = alpha * alpha / b2 - 1.0 ; double inner = bb * bb - 4.0 * aa * cc ; if ( Math . abs ( inner / aa ) < EPS ) { // divide by aa for scale invariance
totalIntersections = 1 ; inner = inner < 0 ? 0 : inner ; } else if ( inner < 0 ) { return 0 ; } else { totalIntersections = 2 ; } double right = Math . sqrt ( inner ) ; x0 = ( - bb + right ) / ( 2.0 * aa ) ; x1 = ( - bb - right ) / ( 2.0 * aa ) ; y0 = - ( A * x0 + C ) / B ; y1 = - ( A * x1 + C ) / B ; } // go back into world coordinate system
intersection0 . x = x0 * cphi - y0 * sphi + ellipse . center . x ; intersection0 . y = x0 * sphi + y0 * cphi + ellipse . center . y ; intersection1 . x = x1 * cphi - y1 * sphi + ellipse . center . x ; intersection1 . y = x1 * sphi + y1 * cphi + ellipse . center . y ; return totalIntersections ;


signature:
public class ConvertRotation3D_F64 { /** * Converts { @ link georegression . struct . so . Rodrigues _ F64 } into a rotation matrix .
 * @ param rodrigues rotation defined using rotation axis angle notation .
 * @ param R where the results will be stored . If null a new matrix is declared internally .
 * @ return rotation matrix . */
public static DMatrixRMaj rodriguesToMatrix ( Rodrigues_F64 rodrigues , DMatrixRMaj R ) { } }

implementation: return rodriguesToMatrix ( rodrigues . unitAxisRotation . x , rodrigues . unitAxisRotation . y , rodrigues . unitAxisRotation . z , rodrigues . theta , R ) ;


signature:
public class ConvertRotation3D_F64 { /** * Converts axis angle ( { @ link Rodrigues _ F64 } ) into a rotation matrix with out needing to declare a storage
 * variable .
 * @ param axisX x - component of normalized rotation vector
 * @ param axisY y - component of normalized rotation vector
 * @ param axisZ z - component of normalized rotation vector
 * @ param theta magnitude of rotation in radians
 * @ param R ( Optional ) storage for 3x3 rotation matrix . If null one will be declared internally .
 * @ return Rotation matrix . */
public static DMatrixRMaj rodriguesToMatrix ( double axisX , double axisY , double axisZ , double theta , DMatrixRMaj R ) { } }

implementation:
R = checkDeclare3x3 ( R ) ; // noinspection UnnecessaryLocalVariable
double x = axisX , y = axisY , z = axisZ ; double c = Math . cos ( theta ) ; double s = Math . sin ( theta ) ; double oc = 1.0 - c ; R . data [ 0 ] = c + x * x * oc ; R . data [ 1 ] = x * y * oc - z * s ; R . data [ 2 ] = x * z * oc + y * s ; R . data [ 3 ] = y * x * oc + z * s ; R . data [ 4 ] = c + y * y * oc ; R . data [ 5 ] = y * z * oc - x * s ; R . data [ 6 ] = z * x * oc - y * s ; R . data [ 7 ] = z * y * oc + x * s ; R . data [ 8 ] = c + z * z * oc ; return R ;


signature:
public class ConvertRotation3D_F64 { /** * < p > Converts { @ link georegression . struct . so . Rodrigues _ F64 } into an euler rotation of different types < / p >
 * @ param rodrigues rotation defined using rotation axis angle notation .
 * @ param type Type of Euler rotation
 * @ param euler ( Output ) Optional storage for Euler rotation
 * @ return The Euler rotation . */
public static double [ ] rodriguesToEuler ( Rodrigues_F64 rodrigues , EulerType type , double [ ] euler ) { } }

implementation: DMatrixRMaj R = rodriguesToMatrix ( rodrigues , null ) ; return matrixToEuler ( R , type , euler ) ;


signature:
public class ConvertRotation3D_F64 { /** * Converts { @ link georegression . struct . so . Rodrigues _ F64 } into a unit { @ link georegression . struct . so . Quaternion _ F64 } .
 * @ param rodrigues The angle of rotation around the rotation axis .
 * @ param quat Storage for quaternion coordinate . If null a new quaternion is created . Modified .
 * @ return unit quaternion coordinate . */
public static Quaternion_F64 rodriguesToQuaternion ( Rodrigues_F64 rodrigues , Quaternion_F64 quat ) { } }

implementation: if ( quat == null ) quat = new Quaternion_F64 ( ) ; quat . w = Math . cos ( rodrigues . theta / 2.0 ) ; double s = Math . sin ( rodrigues . theta / 2.0 ) ; quat . x = rodrigues . unitAxisRotation . x * s ; quat . y = rodrigues . unitAxisRotation . y * s ; quat . z = rodrigues . unitAxisRotation . z * s ; return quat ;


signature:
public class ConvertRotation3D_F64 { /** * Converts a unit { @ link Quaternion _ F64 } into { @ link Rodrigues _ F64 } .
 * @ param quat ( Input ) Unit quaternion
 * @ param rodrigues ( Optional ) Storage for rodrigues coodinate . If null a new instance is created .
 * @ return rodrigues */
public static Rodrigues_F64 quaternionToRodrigues ( Quaternion_F64 quat , Rodrigues_F64 rodrigues ) { } }

implementation: if ( rodrigues == null ) rodrigues = new Rodrigues_F64 ( ) ; rodrigues . unitAxisRotation . set ( quat . x , quat . y , quat . z ) ; rodrigues . unitAxisRotation . normalize ( ) ; rodrigues . theta = 2.0 * Math . acos ( quat . w ) ; return rodrigues ;


signature:
public class ConvertRotation3D_F64 { /** * < p > Converts a quaternion into an euler rotation of different types < / p >
 * @ param q ( Input ) Normalized quaternion . Not modified .
 * @ param type Type of Euler rotation
 * @ param euler ( Output ) Optional storage for Euler rotation
 * @ return The Euler rotation . */
public static double [ ] quaternionToEuler ( Quaternion_F64 q , EulerType type , double [ ] euler ) { } }

implementation: DMatrixRMaj R = quaternionToMatrix ( q , null ) ; return matrixToEuler ( R , type , euler ) ;


signature:
public class ConvertRotation3D_F64 { /** * < p > Converts a rotation matrix into an Euler angle of different types < / p >
 * @ param R ( Input ) Rotation matrix . Not modified .
 * @ param type Type of Euler rotation
 * @ param euler ( Output ) Optional storage for Euler rotation
 * @ return The Euler rotation . */
public static double [ ] matrixToEuler ( DMatrixRMaj R , EulerType type , double [ ] euler ) { } }

implementation: if ( euler == null ) euler = new double [ 3 ] ; switch ( type ) { case ZYX : TanSinTan ( - 2 , 1 , 3 , - 6 , 9 , 5 , - 7 , 4 , 8 , R , euler ) ; break ; case ZYZ : TanCosTan ( 8 , - 7 , 9 , 6 , 3 , 5 , - 7 , 4 , 8 , R , euler ) ; break ; case ZXY : TanSinTan ( 4 , 5 , - 6 , 3 , 9 , 1 , 8 , - 2 , 7 , R , euler ) ; break ; case ZXZ : TanCosTan ( 7 , 8 , 9 , 3 , - 6 , 1 , 8 , - 2 , 7 , R , euler ) ; break ; case YXZ : TanSinTan ( - 7 , 9 , 8 , - 2 , 5 , 1 , - 6 , 3 , 4 , R , euler ) ; break ; case YXY : TanCosTan ( 4 , - 6 , 5 , 2 , 8 , 1 , - 6 , 3 , 4 , R , euler ) ; break ; case YZX : TanSinTan ( 3 , 1 , - 2 , 8 , 5 , 9 , 4 , - 7 , 6 , R , euler ) ; break ; case YZY : TanCosTan ( 6 , 4 , 5 , 8 , - 2 , 9 , 4 , - 7 , 6 , R , euler ) ; break ; case XYZ : TanSinTan ( 8 , 9 , - 7 , 4 , 1 , 5 , 3 , - 6 , 2 , R , euler ) ; break ; case XYX : TanCosTan ( 2 , 3 , 1 , 4 , - 7 , 5 , 3 , - 6 , 2 , R , euler ) ; break ; case XZY : TanSinTan ( - 6 , 5 , 4 , - 7 , 1 , 9 , - 2 , 8 , 3 , R , euler ) ; break ; case XZX : TanCosTan ( 3 , - 2 , 1 , 7 , 4 , 9 , - 2 , 8 , 3 , R , euler ) ; break ; default : throw new IllegalArgumentException ( "Unknown rotation sequence" ) ; } return euler ;


signature:
public class ConvertRotation3D_F64 { /** * If the index is negative it returns the negative of the value at - index . Starts at 0 */
private static double get ( DMatrixRMaj M , int index ) { } }

implementation: if ( index < 0 ) { return - M . data [ - index - 1 ] ; } else { return M . data [ index - 1 ] ; }


signature:
public class ConvertRotation3D_F64 { /** * Extracts quaternions from the provided rotation matrix .
 * @ param R ( Input ) rotation matrix
 * @ param quat ( Output ) Optional storage for quaternion . If null a new class will be used .
 * @ return unit quaternion representation of the rotation matrix . */
public static Quaternion_F64 matrixToQuaternion ( DMatrixRMaj R , Quaternion_F64 quat ) { } }

implementation:
if ( quat == null ) quat = new Quaternion_F64 ( ) ; // algorithm from :
// http : / / www . euclideanspace . com / maths / geometry / rotations / conversions / matrixToQuaternion /
// Designed to minimize numerical error by not dividing by very small numbers
double m00 = R . unsafe_get ( 0 , 0 ) ; double m01 = R . unsafe_get ( 0 , 1 ) ; double m02 = R . unsafe_get ( 0 , 2 ) ; double m10 = R . unsafe_get ( 1 , 0 ) ; double m11 = R . unsafe_get ( 1 , 1 ) ; double m12 = R . unsafe_get ( 1 , 2 ) ; double m20 = R . unsafe_get ( 2 , 0 ) ; double m21 = R . unsafe_get ( 2 , 1 ) ; double m22 = R . unsafe_get ( 2 , 2 ) ; double trace = m00 + m11 + m22 ; if ( trace > 0 ) { double S = Math . sqrt ( trace + 1.0 ) * 2 ; // S = 4 * qw
quat . w = 0.25 * S ; quat . x = ( m21 - m12 ) / S ; quat . y = ( m02 - m20 ) / S ; quat . z = ( m10 - m01 ) / S ; } else if ( ( m00 > m11 ) & ( m00 > m22 ) ) { double S = Math . sqrt ( 1.0 + m00 - m11 - m22 ) * 2 ; // S = 4 * qx
quat . w = ( m21 - m12 ) / S ; quat . x = 0.25 * S ; quat . y = ( m01 + m10 ) / S ; quat . z = ( m02 + m20 ) / S ; } else if ( m11 > m22 ) { double S = Math . sqrt ( 1.0 + m11 - m00 - m22 ) * 2 ; // S = 4 * qy
quat . w = ( m02 - m20 ) / S ; quat . x = ( m01 + m10 ) / S ; quat . y = 0.25 * S ; quat . z = ( m12 + m21 ) / S ; } else { double S = Math . sqrt ( 1.0 + m22 - m00 - m11 ) * 2 ; // S = 4 * qz
quat . w = ( m10 - m01 ) / S ; quat . x = ( m02 + m20 ) / S ; quat . y = ( m12 + m21 ) / S ; quat . z = 0.25 * S ; } return quat ;


signature:
public class ConvertRotation3D_F64 { /** * Converts a rotation matrix into { @ link georegression . struct . so . Rodrigues _ F64 } .
 * @ param R Rotation matrix .
 * @ param rodrigues Storage used for solution . If null a new instance is declared .
 * @ return The found axis and rotation angle . */
public static Rodrigues_F64 matrixToRodrigues ( DMatrixRMaj R , Rodrigues_F64 rodrigues ) { } }

implementation:
if ( rodrigues == null ) { rodrigues = new Rodrigues_F64 ( ) ; } // parts of this are from wikipedia
// http : / / en . wikipedia . org / wiki / Rotation _ representation _ % 28mathematics % 29 # Rotation _ matrix _ . E2.86.94 _ Euler _ axis . 2Fangle
double diagSum = ( ( R . unsafe_get ( 0 , 0 ) + R . unsafe_get ( 1 , 1 ) + R . unsafe_get ( 2 , 2 ) ) - 1.0 ) / 2.0 ; double absDiagSum = Math . abs ( diagSum ) ; if ( absDiagSum <= 1.0 && 1.0 - absDiagSum > 10.0 * GrlConstants . EPS ) { // if numerically stable use a faster technique
rodrigues . theta = Math . acos ( diagSum ) ; double bottom = 2.0 * Math . sin ( rodrigues . theta ) ; // in cases where bottom is close to zero that means theta is also close to zero and the vector
// doesn ' t matter that much
rodrigues . unitAxisRotation . x = ( R . unsafe_get ( 2 , 1 ) - R . unsafe_get ( 1 , 2 ) ) / bottom ; rodrigues . unitAxisRotation . y = ( R . unsafe_get ( 0 , 2 ) - R . unsafe_get ( 2 , 0 ) ) / bottom ; rodrigues . unitAxisRotation . z = ( R . unsafe_get ( 1 , 0 ) - R . unsafe_get ( 0 , 1 ) ) / bottom ; // in extreme underflow situations the result can be unnormalized
rodrigues . unitAxisRotation . normalize ( ) ; // In theory this might be more stable
// rotationAxis ( R , rodrigues . unitAxisRotation ) ;
} else { // this handles the special case where the bottom is very very small or equal to zero
if ( diagSum >= 1.0 ) rodrigues . theta = 0 ; else if ( diagSum <= - 1.0 ) rodrigues . theta = Math . PI ; else rodrigues . theta = Math . acos ( diagSum ) ; // compute the value of x , y , z up to a sign ambiguity
rodrigues . unitAxisRotation . x = Math . sqrt ( ( R . get ( 0 , 0 ) + 1 ) / 2 ) ; rodrigues . unitAxisRotation . y = Math . sqrt ( ( R . get ( 1 , 1 ) + 1 ) / 2 ) ; rodrigues . unitAxisRotation . z = Math . sqrt ( ( R . get ( 2 , 2 ) + 1 ) / 2 ) ; double x = rodrigues . unitAxisRotation . x ; double y = rodrigues . unitAxisRotation . y ; double z = rodrigues . unitAxisRotation . z ; if ( Math . abs ( R . get ( 1 , 0 ) - 2 * x * y ) > GrlConstants . EPS ) { x *= - 1 ; } if ( Math . abs ( R . get ( 2 , 0 ) - 2 * x * z ) > GrlConstants . EPS ) { z *= - 1 ; } if ( Math . abs ( R . get ( 2 , 1 ) - 2 * z * y ) > GrlConstants . EPS ) { y *= - 1 ; x *= - 1 ; } rodrigues . unitAxisRotation . x = x ; rodrigues . unitAxisRotation . y = y ; rodrigues . unitAxisRotation . z = z ; } return rodrigues ;


signature:
public class ConvertRotation3D_F64 { /** * Creates a rotation matrix about the x - axis .
 * @ param ang the angle it rotates a point by in radians .
 * @ param R ( Output ) Optional storage for rotation matrix . Modified .
 * @ return The 3 by 3 rotation matrix . */
public static DMatrixRMaj rotX ( double ang , DMatrixRMaj R ) { } }

implementation: if ( R == null ) R = new DMatrixRMaj ( 3 , 3 ) ; setRotX ( ang , R ) ; return R ;


signature:
public class ConvertRotation3D_F64 { /** * Sets the values in the specified matrix to a rotation matrix about the x - axis .
 * @ param ang the angle it rotates a point by in radians .
 * @ param R ( Output ) Storage for rotation matrix . Modified . */
public static void setRotX ( double ang , DMatrixRMaj R ) { } }

implementation: double c = Math . cos ( ang ) ; double s = Math . sin ( ang ) ; R . set ( 0 , 0 , 1 ) ; R . set ( 1 , 1 , c ) ; R . set ( 1 , 2 , - s ) ; R . set ( 2 , 1 , s ) ; R . set ( 2 , 2 , c ) ;


signature:
public class ConvertRotation3D_F64 { /** * Creates a rotation matrix about the y - axis .
 * @ param ang the angle it rotates a point by in radians .
 * @ param R ( Output ) Optional storage for rotation matrix . Modified .
 * @ return The 3 by 3 rotation matrix . */
public static DMatrixRMaj rotY ( double ang , DMatrixRMaj R ) { } }

implementation: R = checkDeclare3x3 ( R ) ; setRotY ( ang , R ) ; return R ;


signature:
public class ConvertRotation3D_F64 { /** * Creates a rotation matrix about the z - axis .
 * @ param ang the angle it rotates a point by in radians .
 * @ param R ( Output ) Optional storage for rotation matrix . Modified .
 * @ return The 3 by 3 rotation matrix . */
public static DMatrixRMaj rotZ ( double ang , DMatrixRMaj R ) { } }

implementation: R = checkDeclare3x3 ( R ) ; setRotZ ( ang , R ) ; return R ;


signature:
public class ConvertRotation3D_F64 { /** * Sets the values in the specified matrix to a rotation matrix about the z - axis .
 * @ param ang the angle it rotates a point by in radians .
 * @ param r A 3 by 3 matrix . Is modified . */
public static void setRotZ ( double ang , DMatrixRMaj r ) { } }

implementation: double c = Math . cos ( ang ) ; double s = Math . sin ( ang ) ; r . set ( 0 , 0 , c ) ; r . set ( 0 , 1 , - s ) ; r . set ( 1 , 0 , s ) ; r . set ( 1 , 1 , c ) ; r . set ( 2 , 2 , 1 ) ;


signature:
public class ConvertRotation3D_F64 { /** * Converts an Euler coordinate into a rotation matrix . Different type of Euler coordinates are accepted .
 * @ param type Which Euler coordinate is the input in
 * @ param rotA Angle of rotation around axis A . First rotation
 * @ param rotB Angle of rotation around axis B Second rotation
 * @ param rotC Angle of rotation around axis C Third rotation
 * @ param R ( Output ) Optional storage for output rotation matrix
 * @ return Rotation matrix */
public static DMatrixRMaj eulerToMatrix ( EulerType type , double rotA , double rotB , double rotC , DMatrixRMaj R ) { } }

implementation: R = checkDeclare3x3 ( R ) ; DMatrixRMaj R_a = rotationAboutAxis ( type . getAxisA ( ) , rotA , null ) ; DMatrixRMaj R_b = rotationAboutAxis ( type . getAxisB ( ) , rotB , null ) ; DMatrixRMaj R_c = rotationAboutAxis ( type . getAxisC ( ) , rotC , null ) ; DMatrixRMaj A = new DMatrixRMaj ( 3 , 3 ) ; CommonOps_DDRM . mult ( R_b , R_a , A ) ; CommonOps_DDRM . mult ( R_c , A , R ) ; return R ;


signature:
public class ConvertRotation3D_F64 { /** * Creates a rotation matrix about the specified axis .
 * @ param axis 0 = x , 1 = y , 2 = z
 * @ param angle The angle it is rotated by in radians .
 * @ return The 3 by 3 rotation matrix . */
private static DMatrixRMaj rotationAboutAxis ( int axis , double angle , DMatrixRMaj R ) { } }

implementation: switch ( axis ) { case 0 : return ConvertRotation3D_F64 . rotX ( angle , R ) ; case 1 : return ConvertRotation3D_F64 . rotY ( angle , R ) ; case 2 : return ConvertRotation3D_F64 . rotZ ( angle , R ) ; default : throw new IllegalArgumentException ( "Unknown which" ) ; }


signature:
public class ConvertRotation3D_F64 { /** * Finds a rotation matrix which is the optimal approximation to an arbitrary 3 by 3 matrix . Optimality
 * is specified by the equation below : < br >
 * < br >
 * min | | R - Q | | < sup > 2 < / sup > < sub > F < / sub > < br >
 * R < br >
 * where R is the rotation matrix and Q is the matrix being approximated .
 * The technique used is based on SVD and is described in Appendix C of " A Flexible New Technique for
 * Camera Calibration " Technical Report , updated 2002.
 * Both origin and R can be the same instance .
 * @ param orig Input approximate rotation matrix . Not modified .
 * @ param R ( Optional ) Storage for the approximated rotation matrix . Modified .
 * @ return Rotation matrix */
public static DMatrixRMaj approximateRotationMatrix ( DMatrixRMaj orig , DMatrixRMaj R ) { } }

implementation:
R = checkDeclare3x3 ( R ) ; SingularValueDecomposition < DMatrixRMaj > svd = DecompositionFactory_DDRM . svd ( orig . numRows , orig . numCols , true , true , false ) ; if ( ! svd . decompose ( orig ) ) throw new RuntimeException ( "SVD Failed" ) ; CommonOps_DDRM . mult ( svd . getU ( null , false ) , svd . getV ( null , true ) , R ) ; // svd does not guarantee that U anv V have positive determinants .
double det = CommonOps_DDRM . det ( R ) ; if ( det < 0 ) CommonOps_DDRM . scale ( - 1 , R ) ; return R ;


signature:
public class ConvertRotation3D_F64 { /** * < p > Converts a unit quaternion into a rotation matrix . < / p >
 * Equations is taken from : Paul J . Besl and Neil D . McKay , " A Method for Registration of 3 - D Shapes " IEEE
 * Transactions on Pattern Analysis and Machine Intelligence , Vol 14 , No . 2 , Feb . 1992
 * @ param quat Unit quaternion .
 * @ param R Storage for rotation matrix . If null a new matrix is created . Modified .
 * @ return Rotation matrix */
public static DMatrixRMaj quaternionToMatrix ( Quaternion_F64 quat , DMatrixRMaj R ) { } }

implementation: return quaternionToMatrix ( quat . w , quat . x , quat . y , quat . z , R ) ;


signature:
public class LineParametric2D_F64 { /** * Sets the slope to the unit vector specified by the provided angle .
 * @ param angle Angle of the line specified in radians . */
public void setAngle ( double angle ) { } }

implementation: slope . set ( Math . cos ( angle ) , Math . sin ( angle ) ) ;


signature:
public class LineParametric2D_F64 { /** * Returns a point along the line . See parametric equation in class description .
 * @ param t Location along the line .
 * @ return Point on the line . */
public Point2D_F64 getPointOnLine ( double t ) { } }

implementation: return new Point2D_F64 ( slope . x * t + p . x , slope . y * t + p . y ) ;


signature:
public class TwistOps_F64 { /** * Converts the { @ link Se3 _ F64 } object into homogenous notation . < br >
 * [ R , T ; 0 , 1]
 * @ param transform transform in regular SE3 format . If null a new matrix will be declared
 * @ param H ( Optional ) Storage for homogenous 4x4 matrix . If null a new matrix is declared .
 * @ return Homogenous matrix */
public static DMatrixRMaj homogenous ( Se3_F64 transform , DMatrixRMaj H ) { } }

implementation: if ( H == null ) { H = new DMatrixRMaj ( 4 , 4 ) ; } else { H . reshape ( 4 , 4 ) ; } CommonOps_DDRM . insert ( transform . R , H , 0 , 0 ) ; H . data [ 3 ] = transform . T . x ; H . data [ 7 ] = transform . T . y ; H . data [ 11 ] = transform . T . z ; H . data [ 12 ] = 0 ; H . data [ 13 ] = 0 ; H . data [ 14 ] = 0 ; H . data [ 15 ] = 1 ; return H ;


signature:
public class TwistOps_F64 { /** * Converts the twist coordinate into homogenous format . < br >
 * H = [ hat ( w ) , v ; 0 , 0]
 * @ param twist Twist coordinate
 * @ param H ( Optional ) Storage for homogenous 4x4 matrix . If null a new matrix is declared .
 * @ return Homogenous matrix */
public static DMatrixRMaj homogenous ( TwistCoordinate_F64 twist , DMatrixRMaj H ) { } }

implementation: if ( H == null ) { H = new DMatrixRMaj ( 4 , 4 ) ; } else { H . reshape ( 4 , 4 ) ; H . data [ 12 ] = 0 ; H . data [ 13 ] = 0 ; H . data [ 14 ] = 0 ; H . data [ 15 ] = 0 ; } H . data [ 0 ] = 0 ; H . data [ 1 ] = - twist . w . z ; H . data [ 2 ] = twist . w . y ; H . data [ 3 ] = twist . v . x ; H . data [ 4 ] = twist . w . z ; H . data [ 5 ] = 0 ; H . data [ 6 ] = - twist . w . x ; H . data [ 7 ] = twist . v . y ; H . data [ 8 ] = - twist . w . y ; H . data [ 9 ] = twist . w . x ; H . data [ 10 ] = 0 ; H . data [ 11 ] = twist . v . z ; return H ;


signature:
public class TwistOps_F64 { /** * Computes the exponential map for a twist : < br >
 * exp ( hat ( xi ) * theta ) = [ SO , ( I - SO ) * ( w cross v ) + w * w < sup > T < / sup > v & Theta ; 0 , 1 ] < br >
 * SO = exp ( hat ( w ) * theta )
 * See page 42 in R . Murray , et . al . " A Mathematical Introduction to ROBOTIC MANIPULATION " 1994
 * @ param twist Twist coordinate
 * @ param theta Magnitude of rotation
 * @ param motion Storage for SE ( 3 ) . If null a new instance will be returned .
 * @ return The transformation . */
public static Se3_F64 exponential ( TwistCoordinate_F64 twist , double theta , Se3_F64 motion ) { } }

implementation:
if ( motion == null ) { motion = new Se3_F64 ( ) ; } double w_norm = twist . w . norm ( ) ; if ( w_norm == 0.0 ) { CommonOps_DDRM . setIdentity ( motion . R ) ; motion . T . x = twist . v . x * theta ; motion . T . y = twist . v . y * theta ; motion . T . z = twist . v . z * theta ; return motion ; } DMatrixRMaj R = motion . getR ( ) ; // First handle the SO region . This Rodrigues equation
double wx = twist . w . x / w_norm , wy = twist . w . y / w_norm , wz = twist . w . z / w_norm ; ConvertRotation3D_F64 . rodriguesToMatrix ( wx , wy , wz , theta * w_norm , R ) ; theta *= w_norm ; // Now compute the translational component
// ( I - SO ) * ( w cross v ) + w * w ' * v * theta
double vx = twist . v . x , vy = twist . v . y , vz = twist . v . z ; double wv_x = wy * vz - wz * vy ; double wv_y = wz * vx - wx * vz ; double wv_z = wx * vy - wy * vx ; double left_x = ( 1 - R . data [ 0 ] ) * wv_x - R . data [ 1 ] * wv_y - R . data [ 2 ] * wv_z ; double left_y = - R . data [ 3 ] * wv_x + ( 1 - R . data [ 4 ] ) * wv_y - R . data [ 5 ] * wv_z ; double left_z = - R . data [ 6 ] * wv_x - R . data [ 7 ] * wv_y + ( 1 - R . data [ 8 ] ) * wv_z ; double right_x = ( wx * wx * vx + wx * wy * vy + wx * wz * vz ) * theta ; double right_y = ( wy * wx * vx + wy * wy * vy + wy * wz * vz ) * theta ; double right_z = ( wz * wx * vx + wz * wy * vy + wz * wz * vz ) * theta ; motion . T . x = ( double ) left_x + right_x ; motion . T . y = ( double ) left_y + right_y ; motion . T . z = ( double ) left_z + right_z ; motion . T . divide ( w_norm ) ; return motion ;


signature:
public class TwistOps_F64 { /** * Converts a rigid body motion into a twist coordinate . The value of theta used to generate the motion
 * is assumed to be one .
 * @ param motion ( Input ) The SE ( 3 ) transformation
 * @ param twist ( Output ) Storage for twist .
 * @ return magnitude of the motion */
public static TwistCoordinate_F64 twist ( Se3_F64 motion , TwistCoordinate_F64 twist ) { } }

implementation:
if ( twist == null ) twist = new TwistCoordinate_F64 ( ) ; if ( MatrixFeatures_DDRM . isIdentity ( motion . R , GrlConstants . TEST_F64 ) ) { twist . w . set ( 0 , 0 , 0 ) ; twist . v . set ( motion . T ) ; } else { Rodrigues_F64 rod = new Rodrigues_F64 ( ) ; ConvertRotation3D_F64 . matrixToRodrigues ( motion . R , rod ) ; twist . w . set ( rod . unitAxisRotation ) ; double theta = rod . theta ; // A = ( I - SO ) * hat ( w ) + w * w ' * theta
DMatrixRMaj A = CommonOps_DDRM . identity ( 3 ) ; CommonOps_DDRM . subtract ( A , motion . R , A ) ; DMatrixRMaj w_hat = GeometryMath_F64 . crossMatrix ( twist . w , null ) ; DMatrixRMaj tmp = A . copy ( ) ; CommonOps_DDRM . mult ( tmp , w_hat , A ) ; Vector3D_F64 w = twist . w ; A . data [ 0 ] += w . x * w . x * theta ; A . data [ 1 ] += w . x * w . y * theta ; A . data [ 2 ] += w . x * w . z * theta ; A . data [ 3 ] += w . y * w . x * theta ; A . data [ 4 ] += w . y * w . y * theta ; A . data [ 5 ] += w . y * w . z * theta ; A . data [ 6 ] += w . z * w . x * theta ; A . data [ 7 ] += w . z * w . y * theta ; A . data [ 8 ] += w . z * w . z * theta ; DMatrixRMaj y = new DMatrixRMaj ( 3 , 1 ) ; y . data [ 0 ] = motion . T . x ; y . data [ 1 ] = motion . T . y ; y . data [ 2 ] = motion . T . z ; DMatrixRMaj x = new DMatrixRMaj ( 3 , 1 ) ; CommonOps_DDRM . solve ( A , y , x ) ; twist . w . scale ( rod . theta ) ; twist . v . x = ( double ) x . data [ 0 ] ; twist . v . y = ( double ) x . data [ 1 ] ; twist . v . z = ( double ) x . data [ 2 ] ; twist . v . scale ( rod . theta ) ; } return twist ;


signature:
public class InterpolateLinearSe3_F64 { /** * Specify the two transforms which values are to be interpolated between
 * @ param initial first transform
 * @ param end second transform */
public void setTransforms ( Se3_F64 initial , Se3_F64 end ) { } }

implementation: this . initial . set ( initial ) ; translation . x = end . T . x - initial . T . x ; translation . y = end . T . y - initial . T . y ; translation . z = end . T . z - initial . T . z ; CommonOps_DDRM . multTransA ( initial . getR ( ) , end . getR ( ) , R ) ; ConvertRotation3D_F64 . matrixToRodrigues ( R , rotation ) ; rotMagnitude = rotation . theta ;


signature:
public class InterpolateLinearSe3_F64 { /** * Interpolates a value between the first and second transform . A value close to 0 will be
 * more similar to the initial and 1 more similar to the end .
 * @ param where A value between 0 and 1 which specifies the interpolation location
 * @ param output Resulting transform */
public void interpolate ( double where , Se3_F64 output ) { } }

implementation: rotation . setTheta ( where * rotMagnitude ) ; ConvertRotation3D_F64 . rodriguesToMatrix ( rotation , R ) ; output . T . x = initial . T . x + where * translation . x ; output . T . y = initial . T . y + where * translation . y ; output . T . z = initial . T . z + where * translation . z ; CommonOps_DDRM . mult ( initial . R , R , output . R ) ;


signature:
public class Rectangle2D_F64 { /** * Makes sure x0 , y0 is the lower extent and x1 , y1 is the upper extent */
public void enforceExtents ( ) { } }

implementation: if ( p1 . x < p0 . x ) { double tmp = p1 . x ; p1 . x = p0 . x ; p0 . x = tmp ; } if ( p1 . y < p0 . y ) { double tmp = p1 . y ; p1 . y = p0 . y ; p0 . y = tmp ; }


signature:
public class UtilShape3D_F64 { /** * Converts a 2D polygon into a 3D polygon . The 2D points will lie on the x - y plane ( e . g . ( x , y , 0 ) ) and are
 * converted to 3D using polyToWorld .
 * @ param polygon2D ( Input ) polygon
 * @ param polyToWorld ( Output ) transform from 2D to 3D coordinate system .
 * @ param output */
public static void polygon2Dto3D ( Polygon2D_F64 polygon2D , Se3_F64 polyToWorld , FastQueue < Point3D_F64 > output ) { } }

implementation: output . resize ( polygon2D . size ( ) ) ; for ( int i = 0 ; i < polygon2D . size ( ) ; i ++ ) { Point2D_F64 p2 = polygon2D . get ( i ) ; Point3D_F64 p3 = output . get ( i ) ; p3 . set ( p2 . x , p2 . y , 0 ) ; SePointOps_F64 . transform ( polyToWorld , p3 , p3 ) ; }


signature:
public class FitLine_F64 { /** * Computes the weighted best fit line to the set of points using the polar line equation . The solution
 * is optimal in the Euclidean sense , see [ 1 ] for more details .
 * [ 1 ] K . Arras , R . Siegwart , " Feature Extraction and Scene Interpretation for Map - Based Navigation
 * and Map Building " Proc . SPIE , Mobile Robotics XIII , Vol . 3210 , 1997
 * @ param points Set of points on the line .
 * @ param weights Weight for each point . weights [ i ] & ge ; 0
 * @ param ret Storage for the line . If null a new line will be declared .
 * @ return Best fit line . or null if sum of weights is zero */
public static LinePolar2D_F64 polar ( List < Point2D_F64 > points , double weights [ ] , LinePolar2D_F64 ret ) { } }

implementation: final int N = points . size ( ) ; double totalWeight = 0 ; for ( int i = 0 ; i < N ; i ++ ) { totalWeight += weights [ i ] ; } if ( totalWeight == 0 ) return null ; if ( ret == null ) ret = new LinePolar2D_F64 ( ) ; double meanX = 0 ; double meanY = 0 ; for ( int i = 0 ; i < N ; i ++ ) { Point2D_F64 p = points . get ( i ) ; double w = weights [ i ] ; meanX += w * p . x ; meanY += w * p . y ; } meanX /= totalWeight ; meanY /= totalWeight ; double top = 0 ; double bottom = 0 ; for ( int i = 0 ; i < N ; i ++ ) { Point2D_F64 p = points . get ( i ) ; double w = weights [ i ] ; double dx = meanX - p . x ; double dy = meanY - p . y ; top += w * dx * dy ; bottom += w * ( dy * dy - dx * dx ) ; } top /= totalWeight ; bottom /= totalWeight ; ret . angle = Math . atan2 ( - 2.0 * top , bottom ) / 2.0 ; ret . distance = ( double ) ( meanX * Math . cos ( ret . angle ) + meanY * Math . sin ( ret . angle ) ) ; return ret ;


signature:
public class FitPlane3D_F64 { /** * SVD based method for fitting a plane to a set of points . The plane ' s equation is returned
 * as a point on the plane and the normal vector .
 * @ param points ( Input ) Set of points on a plane .
 * @ param outputCenter ( Output ) Centroid of the passed in points . Modified .
 * @ param outputNormal ( Output ) Vector tangent to the plane . Normalized . Modified .
 * @ return true if successful or false if it failed . */
public boolean svd ( List < Point3D_F64 > points , Point3D_F64 outputCenter , Vector3D_F64 outputNormal ) { } }

implementation:
final int N = points . size ( ) ; // find the centroid
outputCenter . set ( 0 , 0 , 0 ) ; for ( int i = 0 ; i < N ; i ++ ) { Point3D_F64 p = points . get ( i ) ; outputCenter . x += p . x ; outputCenter . y += p . y ; outputCenter . z += p . z ; } outputCenter . x /= N ; outputCenter . y /= N ; outputCenter . z /= N ; return solvePoint ( points , outputCenter , outputNormal ) ;


signature:
public class FitPlane3D_F64 { /** * SVD based method for fitting a plane to a set of points and a known point on the plane . The plane ' s
 * equation is returned as a point on the plane and the normal vector .
 * @ param points ( Input ) Set of points on a plane .
 * @ param pointOnPlane ( Input ) A known point on the plane
 * @ param outputNormal ( Output ) Vector tangent to the plane . Normalized . Modified .
 * @ return true if successful or false if it failed . */
public boolean solvePoint ( List < Point3D_F64 > points , Point3D_F64 pointOnPlane , Vector3D_F64 outputNormal ) { } }

implementation:
final int N = points . size ( ) ; // construct the matrix
A . reshape ( N , 3 ) ; int index = 0 ; for ( int i = 0 ; i < N ; i ++ ) { Point3D_F64 p = points . get ( i ) ; A . data [ index ++ ] = p . x - pointOnPlane . x ; A . data [ index ++ ] = p . y - pointOnPlane . y ; A . data [ index ++ ] = p . z - pointOnPlane . z ; } // decompose and find the singular value
if ( ! solverNull . process ( A , 1 , nullspace ) ) return false ; // the normal is the singular vector
outputNormal . x = ( double ) nullspace . unsafe_get ( 0 , 0 ) ; outputNormal . y = ( double ) nullspace . unsafe_get ( 1 , 0 ) ; outputNormal . z = ( double ) nullspace . unsafe_get ( 2 , 0 ) ; return true ;


signature:
public class Polygon2D_F64 { /** * Resturns the length of the specified side that is composed of point index and index + 1
 * @ return Euclidean length of the side */
public double getSideLength ( int index ) { } }

implementation: Point2D_F64 a = vertexes . get ( index ) ; Point2D_F64 b = vertexes . get ( ( index + 1 ) % vertexes . size ) ; return ( double ) a . distance ( b ) ;


signature:
public class Polygon2D_F64 { /** * Returns true if the point is inside the polygon . Points along the border are ambiguously considered inside
 * or outside .
 * @ see Intersection2D _ F64 # containConcave ( Polygon2D _ F64 , Point2D _ F64)
 * @ see Intersection2D _ F64 # containConcave ( Polygon2D _ F64 , Point2D _ F64)
 * @ param p A point
 * @ return true if inside and false if outside */
public boolean isInside ( Point2D_F64 p ) { } }

implementation: if ( isConvex ( ) ) { return Intersection2D_F64 . containConvex ( this , p ) ; } else { return Intersection2D_F64 . containConcave ( this , p ) ; }


signature:
public class Polygon2D_F64 { /** * Returns the line / edge defined by vertex index and index + 1.
 * @ param index Index of the line
 * @ return A new instance of the line segment . */
public LineSegment2D_F64 getLine ( int index , LineSegment2D_F64 storage ) { } }

implementation: if ( storage == null ) storage = new LineSegment2D_F64 ( ) ; int j = ( index + 1 ) % vertexes . size ; storage . a . set ( get ( index ) ) ; storage . b . set ( get ( j ) ) ; return storage ;


signature:
public class Polygon2D_F64 { /** * Converts the polygon into a list .
 * @ param storage ( Optional ) storage to put the vertexes into
 * @ param copy If points will be copied otherwise a reference of points will be returned
 * @ return List of vertexes */
public List < Point2D_F64 > convert ( @ Nullable List < Point2D_F64 > storage , boolean copy ) { } }

implementation: if ( storage == null ) storage = new ArrayList < > ( ) ; else storage . clear ( ) ; if ( copy ) { for ( int i = 0 ; i < vertexes . size ; i ++ ) { storage . add ( vertexes . get ( i ) . copy ( ) ) ; } } else { storage . addAll ( vertexes . toList ( ) ) ; } return storage ;


signature:
public class Polygon2D_F64 { /** * Sets the polygon to be the same as the list . A true copy is created and no references
 * to points in the list are saved .
 * @ param list List which the polygon will be set to */
public void set ( List < Point2D_F64 > list ) { } }

implementation: vertexes . resize ( list . size ( ) ) ; for ( int i = 0 ; i < list . size ( ) ; i ++ ) { vertexes . data [ i ] . set ( list . get ( i ) ) ; }


signature:
public class UtilCurves_F64 { /** * Converts symmetric 3x3 matrix back into a conic .
 * < pre >
 * [ A B / 2 D / 2]
 * dst = [ B / 2 C E / 2]
 * [ D / 2 E / 2 F ]
 * < / pre > */
public static DMatrixRMaj convert ( ConicGeneral_F64 src , DMatrixRMaj dst ) { } }

implementation: if ( dst == null ) dst = new DMatrixRMaj ( 3 , 3 ) ; else dst . reshape ( 3 , 3 ) ; double B = src . B / 2.0 ; double D = src . D / 2.0 ; double E = src . E / 2.0 ; dst . data [ 0 ] = src . A ; dst . data [ 1 ] = B ; dst . data [ 2 ] = D ; dst . data [ 3 ] = B ; dst . data [ 4 ] = src . C ; dst . data [ 5 ] = E ; dst . data [ 6 ] = D ; dst . data [ 7 ] = E ; dst . data [ 8 ] = src . F ; return dst ;


signature:
public class UtilCurves_F64 { /** * Converts symmetric 3x3 matrix back into a conic . Only the upper right
 * portion of src is read .
 * < pre >
 * A = DST ( 0,0)
 * B = DST ( 0,1 ) * 2
 * D = DST ( 0,2 ) * 2
 * C = DST ( 1,1)
 * E = DST ( 1,2 ) * 2
 * F = DST ( 2,2)
 * < / pre > */
public static ConicGeneral_F64 convert ( DMatrix3x3 src , ConicGeneral_F64 dst ) { } }

implementation: if ( dst == null ) dst = new ConicGeneral_F64 ( ) ; dst . A = src . a11 ; dst . B = 2 * src . a12 ; dst . D = 2 * src . a13 ; dst . C = src . a22 ; dst . E = 2 * src . a23 ; dst . F = src . a33 ; return dst ;


signature:
public class UtilCurves_F64 { /** * Converts the conic into a symmetric 3x3 matrix
 * < pre >
 * [ A B / 2 D / 2]
 * dst = [ B / 2 C E / 2]
 * [ D / 2 E / 2 F ]
 * < / pre > */
public static DMatrix3x3 convert ( ConicGeneral_F64 src , DMatrix3x3 dst ) { } }

implementation: if ( dst == null ) dst = new DMatrix3x3 ( ) ; double B = src . B / 2.0 ; double D = src . D / 2.0 ; double E = src . E / 2.0 ; dst . a11 = src . A ; dst . a12 = B ; dst . a13 = D ; dst . a21 = B ; dst . a22 = src . C ; dst . a23 = E ; dst . a31 = D ; dst . a32 = E ; dst . a33 = src . F ; return dst ;


signature:
public class UtilCurves_F64 { /** * Converts symmetric 3x3 matrix back into a conic . Only the upper right
 * portion of src is read .
 * < pre >
 * A = DST ( 0,0)
 * B = DST ( 0,1 ) * 2
 * D = DST ( 0,2 ) * 2
 * C = DST ( 1,1)
 * E = DST ( 1,2 ) * 2
 * F = DST ( 2,2)
 * < / pre > */
public static ConicGeneral_F64 convert ( DMatrixRMaj src , ConicGeneral_F64 dst ) { } }

implementation: if ( dst == null ) dst = new ConicGeneral_F64 ( ) ; dst . A = src . data [ 0 ] ; dst . B = 2 * src . data [ 1 ] ; dst . D = 2 * src . data [ 2 ] ; dst . C = src . data [ 4 ] ; dst . E = 2 * src . data [ 5 ] ; dst . F = src . data [ 8 ] ; return dst ;


signature:
public class UtilCurves_F64 { /** * Converts the conic into a parabola . If the conic isn ' t a parabola then it is converted into one
 * by adjusting the value of B .
 * @ param src ( Input ) Conic
 * @ param dst ( Output ) Optional storage for converted parabola
 * @ return Parabola */
public static ParabolaGeneral_F64 convert ( ConicGeneral_F64 src , ParabolaGeneral_F64 dst ) { } }

implementation:
if ( dst == null ) dst = new ParabolaGeneral_F64 ( ) ; // NOTE haven ' t put much through if this is the correct way to handle negative values of A or C
dst . A = Math . signum ( src . A ) * Math . sqrt ( Math . abs ( src . A ) ) ; dst . C = Math . signum ( src . C ) * Math . sqrt ( Math . abs ( src . C ) ) ; dst . D = src . D ; dst . E = src . E ; dst . F = src . F ; return dst ;


signature:
public class UtilCurves_F64 { /** * Converts the parabola into a conic .
 * @ param src ( Input ) Parabola
 * @ param dst ( Output ) Optional storage for converted conic
 * @ return Conic */
public static ConicGeneral_F64 convert ( ParabolaGeneral_F64 src , ConicGeneral_F64 dst ) { } }

implementation: if ( dst == null ) dst = new ConicGeneral_F64 ( ) ; dst . A = src . A * src . A ; dst . B = src . A * src . C * 2.0 ; dst . C = src . C * src . C ; dst . D = src . D ; dst . E = src . E ; dst . F = src . F ; return dst ;


signature: public class UtilCurves_F64 { public static ParabolaParametric_F64 convert ( ParabolaGeneral_F64 src , ParabolaParametric_F64 dst ) { } }

implementation: if ( dst == null ) dst = new ParabolaParametric_F64 ( ) ; double A = src . A ; double C = src . C ; double D = src . D ; double E = src . E ; double F = src . F ; double bottom = C * D - A * E ; if ( bottom == 0 ) { throw new RuntimeException ( "Not a parabola" ) ; } else { dst . A = - C / bottom ; dst . B = E / bottom ; dst . C = - C * F / bottom ; dst . D = A / bottom ; dst . E = - D / bottom ; dst . F = A * F / bottom ; } return dst ;


signature:
public class GeometryMath_F64 { /** * Creates a skew symmetric cross product matrix from the provided tuple .
 * @ param x0 Element 0.
 * @ param x1 Element 1.
 * @ param x2 Element 2.
 * @ param ret If not null the results are stored here , otherwise a new matrix is created .
 * @ return Skew symmetric cross product matrix . */
public static DMatrixRMaj crossMatrix ( double x0 , double x1 , double x2 , DMatrixRMaj ret ) { } }

implementation: if ( ret == null ) { ret = new DMatrixRMaj ( 3 , 3 ) ; } else { ret . zero ( ) ; } ret . set ( 0 , 1 , - x2 ) ; ret . set ( 0 , 2 , x1 ) ; ret . set ( 1 , 0 , x2 ) ; ret . set ( 1 , 2 , - x0 ) ; ret . set ( 2 , 0 , - x1 ) ; ret . set ( 2 , 1 , x0 ) ; return ret ;


signature:
public class GeometryMath_F64 { /** * Creates a skew symmetric cross product matrix from the provided tuple .
 * @ param v Tuple . Not modified .
 * @ param ret If not null the results are stored here , otherwise a new matrix is created .
 * @ return Skew symmetric cross product matrix . */
public static DMatrixRMaj crossMatrix ( GeoTuple3D_F64 v , DMatrixRMaj ret ) { } }

implementation: if ( ret == null ) { ret = new DMatrixRMaj ( 3 , 3 ) ; } else { ret . zero ( ) ; } double x = v . getX ( ) ; double y = v . getY ( ) ; double z = v . getZ ( ) ; ret . set ( 0 , 1 , - z ) ; ret . set ( 0 , 2 , y ) ; ret . set ( 1 , 0 , z ) ; ret . set ( 1 , 2 , - x ) ; ret . set ( 2 , 0 , - y ) ; ret . set ( 2 , 1 , x ) ; return ret ;


signature:
public class GeometryMath_F64 { /** * Computes the cross product : < br >
 * < br >
 * c = a x b
 * @ param a _ x x - coordinate of a
 * @ param a _ y y - coordinate of a
 * @ param a _ z z - coordinate of a
 * @ param b _ x x - coordinate of b
 * @ param b _ y y - coordinate of b
 * @ param b _ z z - coordinate of b
 * @ param c Modified . */
public static void cross ( double a_x , double a_y , double a_z , double b_x , double b_y , double b_z , GeoTuple3D_F64 c ) { } }

implementation: c . x = a_y * b_z - a_z * b_y ; c . y = a_z * b_x - a_x * b_z ; c . z = a_x * b_y - a_y * b_x ;


signature:
public class GeometryMath_F64 { /** * Computes the cross product : < br >
 * < br >
 * c = a x b < br >
 * where ' a ' is in homogeneous coordinates .
 * @ param a Homogeneous coordinates , z = 1 assumed . Not modified .
 * @ param b Not modified .
 * @ param c Modified . */
public static void cross ( GeoTuple2D_F64 a , GeoTuple3D_F64 b , GeoTuple3D_F64 c ) { } }

implementation: c . x = a . y * b . z - b . y ; c . y = b . x - a . x * b . z ; c . z = a . x * b . y - a . y * b . x ;


signature:
public class GeometryMath_F64 { /** * Adds two points together . < br >
 * < br >
 * c = a + b
 * Point ' c ' can be the same instance as ' a ' or ' b ' .
 * @ param a A point . Not modified .
 * @ param b A point . Not modified .
 * @ param c Where the results are stored . Modified . */
public static void add ( GeoTuple3D_F64 a , GeoTuple3D_F64 b , GeoTuple3D_F64 c ) { } }

implementation: c . x = a . x + b . x ; c . y = a . y + b . y ; c . z = a . z + b . z ;


signature:
public class GeometryMath_F64 { /** * Adds two points together while scaling them . < br >
 * < br >
 * pt < sub > 2 < / sub > = a < sub > 0 < / sub > pt < sub > 0 < / sub > + a < sub > 1 < / sub > pt < sub > 1 < / sub >
 * Point ' c ' can be the same instance as ' a ' or ' b ' .
 * @ param a0 Scaling factor for pt0.
 * @ param pt0 A point . Not modified .
 * @ param a1 Scaling factor for pt1.
 * @ param pt1 A point . Not modified .
 * @ param pt2 Where the results are stored . Modified . */
public static void add ( double a0 , GeoTuple3D_F64 pt0 , double a1 , GeoTuple3D_F64 pt1 , GeoTuple3D_F64 pt2 ) { } }


signature:
public class GeometryMath_F64 { /** * < p > ret = p0 + M * p1 < / p >
 * Safe to pass in the same instance of a point more than once . */
public static < T extends GeoTuple3D_F64 > T addMult ( T p0 , DMatrixRMaj M , T p1 , T result ) { } }

implementation: if ( M . numRows != 3 || M . numCols != 3 ) throw new IllegalArgumentException ( "Input matrix must be 3 by 3, not " + M . numRows + " " + M . numCols ) ; if ( result == null ) { result = ( T ) p0 . createNewInstance ( ) ; } double x = p1 . x ; double y = p1 . y ; double z = p1 . z ; result . x = p0 . x + ( double ) ( M . data [ 0 ] * x + M . data [ 1 ] * y + M . data [ 2 ] * z ) ; result . y = p0 . y + ( double ) ( M . data [ 3 ] * x + M . data [ 4 ] * y + M . data [ 5 ] * z ) ; result . z = p0 . z + ( double ) ( M . data [ 6 ] * x + M . data [ 7 ] * y + M . data [ 8 ] * z ) ; return result ;


signature:
public class GeometryMath_F64 { /** * Substracts two points from each other . < br >
 * < br >
 * c = a - b
 * Point ' c ' can be the same instance as ' a ' or ' b ' .
 * @ param a A point . Not modified .
 * @ param b A point . Not modified .
 * @ param c Where the results are stored . Modified . */
public static void sub ( GeoTuple3D_F64 a , GeoTuple3D_F64 b , GeoTuple3D_F64 c ) { } }

implementation: c . x = a . x - b . x ; c . y = a . y - b . y ; c . z = a . z - b . z ;


signature:
public class GeometryMath_F64 { /** * Rotates a 2D point by the specified angle .
 * @ param theta
 * @ param pt
 * @ param solution where the solution is written to . Can be the same point as ' pt ' . */
public static void rotate ( double theta , GeoTuple2D_F64 pt , GeoTuple2D_F64 solution ) { } }

implementation: double c = Math . cos ( theta ) ; double s = Math . sin ( theta ) ; double x = pt . x ; double y = pt . y ; solution . x = c * x - s * y ; solution . y = s * x + c * y ;


signature:
public class GeometryMath_F64 { /** * Rotates a 2D point by the specified angle .
 * @ param c Cosine of theta
 * @ param s Sine of theta
 * @ param pt
 * @ param solution where the solution is written to . Can be the same point as ' pt ' . */
public static void rotate ( double c , double s , GeoTuple2D_F64 pt , GeoTuple2D_F64 solution ) { } }

implementation: double x = pt . x ; double y = pt . y ; solution . x = c * x - s * y ; solution . y = s * x + c * y ;


signature:
public class GeometryMath_F64 { /** * mod = M * pt
 * pt and mod can be the same reference .
 * @ param M
 * @ param pt
 * @ param result Storage for output . Can be the same instance as param ' pt ' . Modified . */
public static < T extends GeoTuple3D_F64 > T mult ( DMatrixRMaj M , T pt , T result ) { } }

implementation: if ( M . numRows != 3 || M . numCols != 3 ) throw new IllegalArgumentException ( "Input matrix must be 3 by 3, not " + M . numRows + " " + M . numCols ) ; if ( result == null ) { result = ( T ) pt . createNewInstance ( ) ; } double x = pt . x ; double y = pt . y ; double z = pt . z ; result . x = ( double ) ( M . data [ 0 ] * x + M . data [ 1 ] * y + M . data [ 2 ] * z ) ; result . y = ( double ) ( M . data [ 3 ] * x + M . data [ 4 ] * y + M . data [ 5 ] * z ) ; result . z = ( double ) ( M . data [ 6 ] * x + M . data [ 7 ] * y + M . data [ 8 ] * z ) ; return ( T ) result ;


signature:
public class GeometryMath_F64 { /** * Computes mod = M * pt , where both pt and mod are in homogeneous coordinates with z assumed to be
 * equal to 1 , and M is a 3x3 matrix .
 * ' pt ' and ' mod ' can be the same point .
 * @ param M 3x3 matrix
 * @ param pt Homogeneous point with z = 1
 * @ param mod Storage for the computation . If null a new point is declared . Can be same instance as pt .
 * @ return Result of computation . */
public static < T extends GeoTuple2D_F64 > T mult ( DMatrixRMaj M , T pt , T mod ) { } }

implementation: if ( M . numRows != 3 || M . numCols != 3 ) throw new IllegalArgumentException ( "Input matrix must be 3 by 3, not " + M . numRows + " " + M . numCols ) ; if ( mod == null ) { throw new IllegalArgumentException ( "Must provide an instance in mod" ) ; } double x = pt . x ; double y = pt . y ; double modz = ( double ) ( M . unsafe_get ( 2 , 0 ) * x + M . unsafe_get ( 2 , 1 ) * y + M . unsafe_get ( 2 , 2 ) ) ; mod . x = ( double ) ( ( M . unsafe_get ( 0 , 0 ) * x + M . unsafe_get ( 0 , 1 ) * y + M . unsafe_get ( 0 , 2 ) ) / modz ) ; mod . y = ( double ) ( ( M . unsafe_get ( 1 , 0 ) * x + M . unsafe_get ( 1 , 1 ) * y + M . unsafe_get ( 1 , 2 ) ) / modz ) ; return mod ;


signature:
public class GeometryMath_F64 { /** * x = P * X
 * @ param P Projective 3x4 matrix
 * @ param X 3D point in homogenous coordinates
 * @ param mod 2D point in homogenous coordinates */
public static void mult ( DMatrixRMaj P , GeoTuple4D_F64 X , GeoTuple3D_F64 mod ) { } }

implementation: if ( P . numRows != 3 || P . numCols != 4 ) throw new IllegalArgumentException ( "Input matrix must be 3 by 4 not " + P . numRows + " " + P . numCols ) ; mod . x = P . data [ 0 ] * X . x + P . data [ 1 ] * X . y + P . data [ 2 ] * X . z + P . data [ 3 ] * X . w ; mod . y = P . data [ 4 ] * X . x + P . data [ 5 ] * X . y + P . data [ 6 ] * X . z + P . data [ 7 ] * X . w ; mod . z = P . data [ 8 ] * X . x + P . data [ 9 ] * X . y + P . data [ 10 ] * X . z + P . data [ 11 ] * X . w ;


signature:
public class GeometryMath_F64 { /** * Computes the following : < br >
 * result = cross ( A ) < sup > T < / sup > * M < br >
 * where M and result are 3x3 matrices , cross ( A ) is the cross product matrix of A .
 * @ param A 2D homogenous coordinate ( implicit z = 1 ) that is internally converted into cross product matrix .
 * @ param M 3x3 matrix .
 * @ param result Storage for results . Can be null .
 * @ return Results . */
public static DMatrixRMaj multCrossATransA ( GeoTuple2D_F64 A , DMatrixRMaj M , DMatrixRMaj result ) { } }

implementation: if ( M . numRows != 3 || M . numCols != 3 ) throw new IllegalArgumentException ( "Input matrix must be 3 by 3, not " + M . numRows + " " + M . numCols ) ; if ( result == null ) { result = new DMatrixRMaj ( 3 , 3 ) ; } double x = A . x ; double y = A . y ; double a11 = M . data [ 0 ] ; double a12 = M . data [ 1 ] ; double a13 = M . data [ 2 ] ; double a21 = M . data [ 3 ] ; double a22 = M . data [ 4 ] ; double a23 = M . data [ 5 ] ; double a31 = M . data [ 6 ] ; double a32 = M . data [ 7 ] ; double a33 = M . data [ 8 ] ; result . data [ 0 ] = a21 - a31 * y ; result . data [ 1 ] = a22 - a32 * y ; result . data [ 2 ] = a23 - a33 * y ; result . data [ 3 ] = - a11 + a31 * x ; result . data [ 4 ] = - a12 + a32 * x ; result . data [ 5 ] = - a13 + a33 * x ; result . data [ 6 ] = a11 * y - a21 * x ; result . data [ 7 ] = a12 * y - a22 * x ; result . data [ 8 ] = a13 * y - a23 * x ; return result ;


signature:
public class GeometryMath_F64 { /** * mod = M < sup > T < / sup > * pt . Both pt and mod can be the same instance . */
public static < T extends GeoTuple3D_F64 > T multTran ( DMatrixRMaj M , T pt , T mod ) { } }

implementation: if ( M . numRows != 3 || M . numCols != 3 ) throw new IllegalArgumentException ( "Rotation matrices are 3 by 3." ) ; if ( mod == null ) { mod = ( T ) pt . createNewInstance ( ) ; } double x = pt . x ; double y = pt . y ; double z = pt . z ; mod . x = ( double ) ( M . unsafe_get ( 0 , 0 ) * x + M . unsafe_get ( 1 , 0 ) * y + M . unsafe_get ( 2 , 0 ) * z ) ; mod . y = ( double ) ( M . unsafe_get ( 0 , 1 ) * x + M . unsafe_get ( 1 , 1 ) * y + M . unsafe_get ( 2 , 1 ) * z ) ; mod . z = ( double ) ( M . unsafe_get ( 0 , 2 ) * x + M . unsafe_get ( 1 , 2 ) * y + M . unsafe_get ( 2 , 2 ) * z ) ; return ( T ) mod ;