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

abstraction bridges
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

Abstraction-bridges

Berend Schotanus First Flamingo Enterprise B.V.

slide-2
SLIDE 2

Contents

  • Background
  • Reductionism - Holism
  • Example: drawing curves in MapKit overlay
slide-3
SLIDE 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?

slide-4
SLIDE 4

What makes this device different?

Not infallible... Yet it feels different, flexible, more natural, Less rigid.

illustratie: apple-history.com

slide-5
SLIDE 5

equation-based → simulation-based

reductionism → holism

analysis → computation

continuous → discrete

linear → non-linear

deterministic → stochastic abstract → detailed

  • ne, two → many

homogeneous → composite

predictive → explanatory

realism → instrumentalism

centralized → decentralized

isolation → interaction

  • n-to-many → many-to-many

top-down → bottom-up

analysis → computation

design → search

Aristotelian logic → many-valued logic

frequentist probability → Bayesianism

  • bjective → subjective

physical law → theory → model

determinism → indeterminism

bron: A.B. Downey, Think Complexity

slide-6
SLIDE 6

Reductionism

illustratie: wikipedia/Alan Chia

slide-7
SLIDE 7

Holism

illustratie: cjouets.fr illustratie: brictechnic.fr

slide-8
SLIDE 8

Abstraction-bridges

Polyester LEGO-blocks Crane Construction-site Town low level of abstraction high level of abstraction

slide-9
SLIDE 9
slide-10
SLIDE 10
slide-11
SLIDE 11
slide-12
SLIDE 12

Processor User low level of abstraction high level of abstraction

OS-X layered architecture

(from: Apple documentation)

slide-13
SLIDE 13

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

slide-14
SLIDE 14

Hardware Traffic control Timetable Train-service Traveller

slide-15
SLIDE 15

Screen Scroll-view Map Infrastructure Train-service

slide-16
SLIDE 16

Drawing curves (1)

How to draw a curve

  • n a map using the

MapKit overlay API

slide-17
SLIDE 17

Drawing curves (2)

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

slide-18
SLIDE 18

MapKit overlay

rendering engine subclass of MKOverlayView protocol MKOverlay your data

drawMapRect:zoomScale:inContext: ask data whatever

struct CGPoint { CGFloat x; CGFloat y; }; typedef struct CGPoint CGPoint; typedef struct { CLLocationDegrees latitude; CLLocationDegrees longitude; } CLLocationCoordinate2D; typedef struct { double x; double y; } MKMapPoint;

slide-19
SLIDE 19

Transformations

  • (MKMapPoint)mapPointForPoint:(CGPoint)point
  • (CGPoint)pointForMapPoint:(MKMapPoint)mapPoint

CGPoint MKMapPoint CLLocation Coordinate2D

MKMapPoint MKMapPointForCoordinate( CLLocationCoordinate2D coordinate ); CLLocationCoordinate2D MKCoordinateForMapPoint( MKMapPoint mapPoint );

slide-20
SLIDE 20

Custom transformations

angle

typedef struct {

  • double angle;
  • double length;

} PolarSize;

length width height

struct CGSize { CGFloat width; CGFloat height; }; typedef struct CGSize CGSize; CGSize cartesianSizeFromPolar(PolarSize polar) {

  • CGSize result;
  • result.width = polar.length * cos(polar.angle);
  • result.height = polar.length * sin(polar.angle);
  • return result;

} 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;

}

slide-21
SLIDE 21

[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); }

slide-22
SLIDE 22

Thank you!

Berend Schotanus mail: BS@BSchotanus.nl web: http://firstflamingo.nl twitter: @schotanus