ftp.nice.ch/pub/next/science/mathematics/HippoDraw.2.0.s.tar.gz#/HippoDraw/Example.m

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

/* Example.m  	by Paul Kunz	July 1993
 * An example of HippoDraw plot function.   It's a
 * straight line as in
 *
 *	y = a + b*x
 *
 * Copyright (C)  1993  The Board of Trustees of
 * The Leland Stanford Junior University. All Rights Reserved.
 */

/* import the super class */
#import "PFunction.h"

/* Declare the interface */
@interface Example : PFunction
{
}

- init;
 /*
  * The designated initialzer and the only method that needs to be
  * implemented..
  */
  
@end

@implementation Example 

/* 
 * The following is the function that will be called for plotting
 * 	double x	is the value along the x-axis
 *	double binW	is the width of histogram bins. You function
 *			should use it as overall scale factor.
 *	double *par	is an array of the function's parameters
 *	double example() returns a double value
 */
static double example(double x, double binW, double *par )
{
    double result;

    result = binW * (par[0]  + par[1]*x);
    return result;
}

/* 
 * The following is the only method that needs to be implemented 
 */
- init
{
    [super init];
    
  /* Set the name of the function as it will appear in the function browser */
    [self setTitle:"Example"];
    
  /* Set the function pointer to the static function above */
    [self setFunctionPtr:example];
    
  /* Set the number of parameters of the function */
    [self setNumberArgs:2];
    
  /* The following must be invoked only after the above is done */
    [self registerFunc];
    
  /* Set the name of the parameters as they will appear
   * in the function browser */
    [self setArgName:"yintercept" at:0];
    [self setArgName:"slope" at:1];
    
  /* That's all folks! */
    return self;
}

@end

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