// (c) MIT 2003.  All rights reserved.

// -*-Mode: Java-*- 
// $Id: Force.java,v 1.3 2003/03/06 00:40:49 moltmans Exp $
// Force.java -- 
// Author: Michael Oltmans <moltmans@ai.mit.edu> 
// Created: <Fri May 26 20:01:44 2000> 
// Time-stamp: <2000-07-19 17:06:36 moltmans> 
package rec.annotate.facts;

import rec.annotate.rules.*;
import java.util.*;
import rec.util.*;
import rec.core.widgets.*;
import rec.geo.*;
import rec.tms.*;

/**
 * This class is for storing information about forces
 **/
public class Force extends Annotation
{
  Body m_body;
  GPoint m_point;
  GPoint m_direction;
  
  public Force( Body body, GPoint point, GPoint direction )
  {
    super( body.getStartTime(), body.getEndTime() );
    m_body = body;
    m_point = new GPoint( point );
    m_direction = new GPoint( direction );
  }

  public Body getBody()
  {
    return m_body;
  }

  public GPoint getPoint()
  {
    return m_point;
  }

  /** @return the angle of the force in radians. **/
  public double getAngle() 
  {
    return m_direction.getAngle();
  }

  public boolean isSameVerticalDirection( Force f ) 
  {
    return !( (m_direction.getY() > 0) ^
	      (f.m_direction.getY() > 0 ) );
  }
  
  public String getFactType() 
  {
    return Type.FORCE;
  }

  public boolean sameFact( Fact fact ) 
  {
    if( fact instanceof Force ) {
      Force force = (Force)fact;
      return ( m_body.equals( force.m_body ) &&
	       m_point.equals( force.m_point ) &&
	       m_direction.equals( force.m_direction ) );
    }
    return false;
  }

  public String toEnglish() 
  {
    return "Force (" +  m_direction + ") on " +
      m_body.toEnglish();
  }

  public String toString() 
  {
    return "<Force on " + m_body + " " + m_direction + ">";
  }
}
