CCL Home Page
Up Directory CCL steraid.c
/**************************************************************************/
/**************************************************************************/
/**************************   "steric"   **********************************/
/**************************************************************************/
/*************     Program to calculate ligand cone    ********************/
/*************     angles as a measure of steric size  ********************/
/**************************************************************************/
/**************************************************************************/

/**************************************************************************/
/******************   Additional Aid Functions   **************************/
/**************************************************************************/
/******************        This module is        **************************/
/******************      system independant      **************************/
/**************************************************************************/

#include 
#include 
#include 

#include "sterdefn.h" /* declaration of structures, functions and globals */
#include "steraid.h"  /* additional functions needed                      */
#include "stertext.h" /* all text functions for text mode                 */

/**************************************************************************/
/***************************************************************************/

char *Last_Character(char *string, char chr)
{
  int i=0,len;
  char *ptr;
  char newline[LINELEN];
  ptr=string;
  len=strlen(string);
  while((*ptr==chr)&&(i64)&&(ch<91))||((ch>96)&&(ch<123))) return(1);
  else return(0);
}

/**************************************************************************/

int Int_String(char *line)
{
  int i,len=strlen(line);
  char newline[LINELEN];
  strcpy(newline,line);
  for(i=0;i57)||(newline[i]<48)) newline[i]=' ';
  i=0;
  if(sscanf(newline,"%d",&i)) return(i);
  return(0);
}

/**************************************************************************/

char *strupr(char *s)
{
  int i;
  for(i=0;s[i]!=0;i++) if((s[i]>96)&&(s[i]<123)) s[i]-=32;
  return(s);
}

/**************************************************************************/

int stricmp(char *s1, char *s2)
{
  char ns1[LINELEN], ns2[LINELEN];
  strcpy(ns1,s1);
  strcpy(ns2,s2);
  strupr(ns1);
  strupr(ns2);
  return(strcmp(ns1,ns2));
}

/**************************************************************************/

double Change_Double(char *title, double val, FILE *input)
{
  char line[LINELEN];

  sprintf(line,"%s (%f):",title,val);
  Get_Input_Line(line,input);
  if (strlen(line)!=0) sscanf(line,"%lf",&val);
  return(val);
}

/**************************************************************************/

int Change_Integer(char *title, int val, FILE *input)
{
  char line[LINELEN];

  sprintf(line,"%s (%d):",title,val);
  Get_Input_Line(line,input);
  if (strlen(line)!=0) sscanf(line,"%d",&val);
  return(val);
}

/**************************************************************************/

long get_next_line(FILE *in, char *string, char *line)
{
  char card[LINELEN];
  int i,len=strlen(string);
  line[0]=0;
  strupr(string);
  while(fgets(line,148,in)!=NULL)
  {
    for(i=0;i0) return(A);
  else return(0.0);
}

/**************************************************************************/

double fmax(double A, double B)
{
  if (A > B) return(A);
  else return(B);
}

/**************************************************************************/

double fmin(double A, double B)
{
  if (A < B) return(A);
  else return(B);
}

/**************************************************************************/

double fmax3(double A, double B, double C)
{
  if(A>B) if(A>C) return(A);
	  else return(C);
  else if(C>B) return (C);
	  else return(B);
}

/**************************************************************************/

double fmin3(double A, double B, double C)
{
  if(A= 0) return(PI/2);
    else return(-PI/2);
  }
  else
  {
    A = atan(Y/X);
    if (A < 0) A = A + PI;
    return(A);
  }
}

/**************************************************************************/

double arcCos(double X)
{
  if (X>1)
  {
    printf("\nArcCos domain error x=%f\n",X);
    return(0.0);
  }
  if (X<-1)
  {
    printf("\nArcCos domain error x=%f\n",X);
    return(PI);
  }
  else return(acos(X));
}

/**************************************************************************/

double cosrule_angle(double A, double B, double C)
{
  double cosalpha;

  if ((A==0.0)||(B==0.0)||(C==0.0)) return(0.0);
  cosalpha = ((A*A)+(B*B)-(C*C))/(2*A*B);
  if (cosalpha>1) {cosalpha=1;printf(" coserr ");}
  if (cosalpha<-1) {cosalpha=-1;printf(" coserr ");}
  return (acos(cosalpha));
}

/**************************************************************************/

int power(int X, int Y)
{
  int count;
  int ans;
  ans=1;
  for(count=0;count
  
Modified: Fri Dec 8 17:00:00 1995 GMT
Page accessed 5394 times since Sat Apr 17 21:59:50 1999 GMT