n-point random route

No, everything is in radians

On Mon, Oct 27, 2014 at 4:33 PM, Fabian <notifications@github.com> wrote:

> In RandomRun/Run.m:
>
> > +        if (resultBlock) {
> > +            resultBlock(routes, nil);
> > +        }
> > +    }];
> > +}
> > +
> > +- (NSArray *)wayPointsForRouteDistance:(CLLocationDistance)distance fromOrigin:(CLLocationCoordinate2D)origin
> > +{
> > +    NSMutableArray *wayPointLocationCoordinates = [[NSMutableArray alloc] initWithObjects:[NSValue valueWithCLLocationCoordinate2D:origin], nil];
> > +    int polygonSides = randomNumberOfLegs();
> > +    float startingAngle = randomStartingAngle();
> > +    float internalAngle = internalAngleInRadiansForPolygonOfNSides(polygonSides);
> > +    int n = 1;
> > +    while (wayPointLocationCoordinates.count < polygonSides) {
> > +        float angleAtWayPoint = startingAngle - ((n - 1) * internalAngle);
> > +        CLLocationDistance xDistance = distance / polygonSides * cosf(angleAtWayPoint);
>
> This is kind of curios. cosf and sinf operate on radians, but you're
> calling them with degrees. You're certainly getting random polygons, but
> not really at the random "angles" you're asking for.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/mojotech/random-run/pull/2/files#r19435069>.
>