Abstraction-bridges
Berend Schotanus First Flamingo Enterprise B.V.
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
Berend Schotanus First Flamingo Enterprise B.V.
Snow, heat, autumn leaves... storm, bomb threat, signal passed at danger... How can the railway system go down like this, time after time?
Not infallible... Yet it feels different, flexible, more natural, Less rigid.
illustratie: apple-history.com
equation-based → simulation-based
analysis → computation
continuous → discrete
linear → non-linear
deterministic → stochastic abstract → detailed
homogeneous → composite
predictive → explanatory
realism → instrumentalism
centralized → decentralized
isolation → interaction
top-down → bottom-up
analysis → computation
design → search
Aristotelian logic → many-valued logic
frequentist probability → Bayesianism
physical law → theory → model
determinism → indeterminism
bron: A.B. Downey, Think Complexity
illustratie: wikipedia/Alan Chia
illustratie: cjouets.fr illustratie: brictechnic.fr
Polyester LEGO-blocks Crane Construction-site Town low level of abstraction high level of abstraction
Processor User low level of abstraction high level of abstraction
OS-X layered architecture
(from: Apple documentation)
Hardware Traffic control Timetable Train-service Traveller
Screen Scroll-view Map Infrastructure Train-service
How to draw a curve
MapKit overlay API
void CGPathAddArc ( CGMutablePathRef path, const CGAffineTransform *m, CGFloat x, CGFloat y, CGFloat radius, CGFloat startAngle, CGFloat endAngle, bool clockwise ); = mapPointA = mapPointB (x, y) = mapPointC
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;
MKMapPoint MKMapPointForCoordinate( CLLocationCoordinate2D coordinate ); CLLocationCoordinate2D MKCoordinateForMapPoint( MKMapPoint mapPoint );
angle
typedef struct {
} PolarSize;
length width height
struct CGSize { CGFloat width; CGFloat height; }; typedef struct CGSize CGSize; CGSize cartesianSizeFromPolar(PolarSize polar) {
} PolarSize polarSizeFromCartesian(CGSize size) {
if (result.length > 0) { if (size.height > 0) { result.angle = acos(size.width/result.length); } else { result.angle = -acos(size.width/result.length); } }
}
{ 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); }