ftp.nice.ch/pub/next/science/mathematics/TotalChaos.1.0.s.tar.gz#/TotalChaos/types/Lorenz.m

This is Lorenz.m in view mode; [Download] [Up]

/* Generated by Interface Builder */

#import "Lorenz.h"
#import <math.h>
#import <stdlib.h>
#import <stdio.h>
#import <appkit/Application.h>
#import <appkit/color.h>
#import <appkit/Form.h>

@implementation Lorenz

- free
{
    [myInspector free];
 /* Free that pesky inspector. */
    [super free];
    return self;
}

- getController:sender :map
{
    [super getController:sender :map];
    [NXApp loadNibSection:"Lorenz.nib" owner:self];
 /* Load the inspector */
    X0 = 20;
 /* Set default values */
    Y0 = 0;
    Z0 = 0;
    DT = 0.02;
    A = 5;
    B = 15;
    C = 1;
    return self;
}

- setValues:sender
{
    X0 = [sender floatValueAt:0];
    Y0 = [sender floatValueAt:1];
    Z0 = [sender floatValueAt:2];
    DT = [sender floatValueAt:3];
    A = [sender floatValueAt:4];
    B = [sender floatValueAt:5];
    C = [sender floatValueAt:6];
    return self;
}

- gohome:(float *)newX :(float *)newY :(float *)newDX :(float *)newDY :(int *)newDepth
{
    *newX = 0.0;
    *newY = 0.0;
    *newDX = 40;
    *newDY = 40;
    *newDepth = 0;
    return self;
}

- (int)colorindex:(double)Real :(double)Imaginary
{
 /*
  * Overwritten for Lorenz set(Will always return setcolor) 
  */
    return (chaosColors);
}

- startM:(float)XCenter :(float)YCenter :(float)XScale :(float)YScale :(int)ThisDepth;
{
    [super startM:XCenter :YCenter :XScale :YScale :ThisDepth];

    X = X0;
    Y = Y0;
    Z = Z0;
    [self lockFocus];
    printf("here");
    NXSetColor(mycolorMap[[self colorindex:0 :0]]);
    NXRectFill(&bounds);
    [self unlockFocus];
    xsize = ysize = 2;
    return self;
}

- drawline
{
    NXRect   myRect;

    [self lockFocus];
    currentCol = (X - myCenterX) * (bounds.size.width / myWidth) + bounds.size.width / 2;
    currentRow = (Y - myCenterY) * (bounds.size.height / myHeight) + bounds.size.height / 2;
    NXSetRect(&myRect, currentCol, currentRow, 1, 1);
#ifdef DEBUG
    printf("cc %f cr %f cC %d\n", X, Y, ((int)Z) % chaosColors);
#endif
    NXSetColor(mycolorMap[((int)Z) % chaosColors]);
    NXRectFill(&myRect);
    X += (-A * X * DT) + (A * Y * DT);
    Y += (B * X * DT) - (Y * DT) - (Z * X * DT);
    Z += (-C * Z * DT) + (X * Y * DT);
    if ((abs(X - myCenterX) > bounds.size.width) || (abs(Y - myCenterY) > bounds.size.height))
	[CVchaosControl runstop:self];
    [self display];
    [self unlockFocus];
    return self;
}

@end

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.