abstraction bridges
play

Abstraction-bridges Berend Schotanus First Flamingo Enterprise B.V. - PowerPoint PPT Presentation

Abstraction-bridges Berend Schotanus First Flamingo Enterprise B.V. Contents Background Reductionism - Holism Example: drawing curves in MapKit overlay My Question: Snow, heat, autumn leaves... storm, bomb threat, signal passed


  1. Abstraction-bridges Berend Schotanus First Flamingo Enterprise B.V.

  2. Contents • Background • Reductionism - Holism • Example: drawing curves in MapKit overlay

  3. My Question: Snow, heat, autumn leaves... storm, bomb threat, signal passed at danger... How can the railway system go down like this, time after time?

  4. What makes this device different? Not infallible... Yet it feels different, flexible, more natural, Less rigid. illustratie: apple-history.com

  5. frequentist probability → Bayesianism analysis → computation homogeneous → composite predictive → explanatory on-to-many → many-to-many analysis → computation equation-based → simulation-based continuous → discrete realism → instrumentalism Aristotelian logic → many-valued logic reductionism → holism centralized → decentralized design → search objective → subjective isolation → interaction linear → non-linear physical law → theory → model deterministic → stochastic determinism → indeterminism abstract → detailed top-down → bottom-up one, two → many bron: A.B. Downey, Think Complexity

  6. Reductionism illustratie: wikipedia/Alan Chia

  7. Holism illustratie: brictechnic.fr illustratie: cjouets.fr

  8. Abstraction-bridges Polyester LEGO-blocks Crane Construction-site Town low level of abstraction high level of abstraction

  9. OS-X layered architecture (from: Apple documentation) Processor User low level of abstraction high level of abstraction

  10. Lessons learned • Railways tend to think in one level of abstraction (timetable) • Finding and connecting appropriate levels of abstraction makes a system more flexible and resilient

  11. Hardware Traffic control Timetable Train-service Traveller

  12. Screen Scroll-view Map Infrastructure Train-service

  13. Drawing curves (1) How to draw a curve on a map using the MapKit overlay API

  14. Drawing curves (2) void CGPathAddArc ( = mapPointA CGMutablePathRef path, const CGAffineTransform *m, CGFloat x, CGFloat y, CGFloat radius, CGFloat startAngle, CGFloat endAngle, bool clockwise ); (x, y) = mapPointC = mapPointB

  15. MapKit overlay drawMapRect:zoomScale:inContext: ask data whatever rendering subclass of protocol your data engine MKOverlayView MKOverlay struct CGPoint { typedef struct { typedef struct { CGFloat x; double x; CLLocationDegrees latitude; CGFloat y; double y; CLLocationDegrees longitude; }; } MKMapPoint; } CLLocationCoordinate2D; typedef struct CGPoint CGPoint;

  16. Transformations CLLocationCoordinate2D MKCoordinateForMapPoint( - (MKMapPoint)mapPointForPoint:(CGPoint) point MKMapPoint mapPoint ); CLLocation CGPoint MKMapPoint Coordinate2D - (CGPoint)pointForMapPoint:(MKMapPoint) mapPoint MKMapPoint MKMapPointForCoordinate( CLLocationCoordinate2D coordinate );

  17. Custom transformations PolarSize polarSizeFromCartesian(CGSize size) { � PolarSize result = polarSizeMake(0, pythagoras(size)); if (result.length > 0) { if (size.height > 0) { result.angle = acos(size.width/result.length); } else { result.angle = -acos(size.width/result.length); } } � return result; } struct CGSize { typedef struct { height CGFloat width; � double angle; CGFloat height; length � double length; }; } PolarSize; typedef struct CGSize CGSize; angle width CGSize cartesianSizeFromPolar(PolarSize polar) { � CGSize result; � result.width = polar.length * cos(polar.angle); � result.height = polar.length * sin(polar.angle); � return result; }

  18. [overlayView drawRect] - (void)drawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale inContext:(CGContextRef)context { RLARoute *route = (RLARoute*)self.overlay; CGMutablePathRef path = CGPathCreateMutable(); [route performOnAllMapPoints:^(MKMapPoint mapPointA, MKMapPoint mapPointB, MKMapPoint mapPointC){ CGPoint curveEnterPoint = [self pointForMapPoint:mapPointA]; CGPoint curveExitPoint = [self pointForMapPoint:mapPointB]; CGPoint curveCenterPoint = [self pointForMapPoint:mapPointC]; PolarSize curveEnterRadial = polarSizeFromCartesian(cartesianSizeFromLine(curveCenterPoint, curveEnterPoint)); PolarSize curveExitRadial = polarSizeFromCartesian(cartesianSizeFromLine(curveCenterPoint, curveExitPoint)); double deltaAngle = rangeMinusPiPlusPi(curveExitRadial.angle - curveEnterRadial.angle); CGPathAddArc(path, NULL, curveCenterPoint.x, curveCenterPoint.y, curveEnterRadial.length, curveEnterRadial.angle, curveExitRadial.angle, deltaAngle < 0); }]; CGContextAddPath(context, path); CGContextSetStrokeColorWithColor(context, [[UIColor blackColor] CGColor]); CGContextSetLineWidth(context, 1.0); CGContextStrokePath(context); CGPathRelease(path); }

  19. Thank you! Berend Schotanus mail: BS@BSchotanus.nl web: http://firstflamingo.nl twitter: @schotanus

Recommend


More recommend