Oolite 1.91.0.7646-241128-10e222e
Loading...
Searching...
No Matches
OOJoystickSplineAxisProfile(Private) Category Reference

Instance Methods

(BOOL) - makeSegments
 

Detailed Description

Definition at line 76 of file OOJoystickProfile.m.

Method Documentation

◆ makeSegments

- (BOOL) makeSegments

Extends class OOJoystickSplineAxisProfile.

Definition at line 39 of file OOJoystickProfile.m.

454{
455 NSUInteger i;
456 NSPoint left, right, next;
457 double gradientleft, gradientright;
459 BOOL first_segment = YES;
460 NSMutableArray *new_segments = [NSMutableArray arrayWithCapacity: ([controlPoints count] + 1)];
461
462 left.x = 0.0;
463 left.y = 0.0;
464 if ([controlPoints count] == 0)
465 {
466 right.x = 1.0;
467 right.y = 1.0;
468 segment = [OOJoystickSplineSegment segmentWithData: left right: right];
469 [new_segments addObject:segment];
470 }
471 else
472 {
473 gradientleft = 1.0;
474 right = [[controlPoints objectAtIndex: 0] pointValue];
475 for (i = 0; i < [controlPoints count]; i++)
476 {
477 next = [self pointAtIndex: i + 1];
478 if (next.x - left.x > 0.0)
479 {
480 // we make the gradient at right equal to the gradient of a straight line between the neighcouring points
481 gradientright = (next.y - left.y)/(next.x - left.x);
482 if (first_segment)
483 {
484 segment = [OOJoystickSplineSegment segmentWithData: left right: right gradientright: gradientright];
485 }
486 else
487 {
488 segment = [OOJoystickSplineSegment segmentWithData: left right: right gradientleft: gradientleft gradientright: gradientright];
489 }
490 if (segment == nil)
491 {
492 return NO;
493 }
494 else
495 {
496 [new_segments addObject: segment];
497 gradientleft = gradientright;
498 first_segment = NO;
499 left = right;
500 }
501 }
502 right = next;
503 }
504 right.x = 1.0;
505 right.y = 1.0;
506 segment = [OOJoystickSplineSegment segmentWithData: left right: right gradientleft: gradientleft];
507 if (segment == nil)
508 {
509 return NO;
510 }
511 [new_segments addObject: segment];
512 }
513 [segments release];
514 segments = [[NSArray arrayWithArray: new_segments] retain];
515 return YES;
516}
517
unsigned count
return nil
id segmentWithData:right:(NSPoint left,[right] NSPoint right)
id segmentWithData:right:gradientleft:(NSPoint left,[right] NSPoint right,[gradientleft] double gradientleft)

The documentation for this category was generated from the following file: