net.algart.model3d.common.movement.model
Class PhysicalMediumResistanceRule

java.lang.Object
  extended by net.algart.model3d.common.movement.model.PhysicalMediumResistanceRule
All Implemented Interfaces:
InteractionRule

public final class PhysicalMediumResistanceRule
extends java.lang.Object
implements InteractionRule

Interaction between the physical medium and any having velocity spherical item. In this class, isApplicable method returns true if and only if byItem instanceof PhysicalMedium, toItem instanceof HavingVelocity and toItem instanceof Spherical, and in this case calculateForce method fills resultXYZ vector by the force F=−2σvr, where v is the velocity vector of toItem, r=toItem.getRadius(), σ=byItem.getResistanceCoefficient().

This class is immutable and thread-safe: there are no ways to modify settings of the created instance.

AlgART Laboratory 2010

Since:
JDK 1.5
Version:
1.0
Author:
Daniel Alievsky

Constructor Summary
Constructor and Description
PhysicalMediumResistanceRule()
           
 
Method Summary
Modifier and Type Method and Description
 boolean calculateForce(double[] resultXYZ, Item toItem, Item byItem, double time)
          Calculates the force F=(Fx,Fy,Fz) of the action of byItem to toItem and returns it in first 3 elements of resultXYZ array (x-component Fx resultXYZ[0], y-component Fy in resultXYZ[1], z-component Fz in resultXYZ[2]).
 boolean isApplicable(Item toItem, Item byItem)
          Checks whether this interaction type is applicable to the given items.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PhysicalMediumResistanceRule

public PhysicalMediumResistanceRule()
Method Detail

isApplicable

public boolean isApplicable(Item toItem,
                            Item byItem)
Description copied from interface: InteractionRule
Checks whether this interaction type is applicable to the given items. If this method returns false, there is a guarantee that InteractionRule.calculateForce(double[], Item, Item, double) method fills its result (first 3 elements of resultXYZ array) by 0.0. If this method returns true, then with high probability InteractionRule.calculateForce(double[], Item, Item, double) method returns a non-zero force.

The arguments of this method can be null; in this case, this method returns false.

Specified by:
isApplicable in interface InteractionRule
Parameters:
toItem - the item to which byItem acts; can be null, then this method returns false.
byItem - the acting item; can be null, then this method returns false.
Returns:
true if this interaction type can be used for this pair; false if byItem cannot act to toItem.

calculateForce

public boolean calculateForce(double[] resultXYZ,
                              Item toItem,
                              Item byItem,
                              double time)
Description copied from interface: InteractionRule
Calculates the force F=(Fx,Fy,Fz) of the action of byItem to toItem and returns it in first 3 elements of resultXYZ array (x-component Fx resultXYZ[0], y-component Fy in resultXYZ[1], z-component Fz in resultXYZ[2]). Returns false if the force is zero. Usually returns true is the force is non-zero, by it is allowed to return true even if it is zero.

This method must work correctly (return false and zero resulting force) also in all situations, when InteractionRule.isApplicable(Item, Item) method returns false.

Specified by:
calculateForce in interface InteractionRule
Parameters:
resultXYZ - resulting force (x-component in resultXYZ[0], y-component in resultXYZ[1], z-component in resultXYZ[2]).
toItem - the item to which byItem acts.
byItem - the acting item.
time - the current time (some interaction can change behaviour in time).
Returns:
if false, there is a guarantee that returned force is zero.


Hot at AlgART: HTML для чайников | Trinity for non-Christians | Диалог с Богом | Religion and Geometry