Class ROTOR

java.lang.Object
com.github.gbenroscience.math.geom.ROTOR

public class ROTOR extends Object
Create a variable or use a constant for the angle Create matrix vectors for O and D Where O is the origin or point about which rotation will occur, and D are the direction coordinates(a,b,c) of the rotation rot(F,angle,origin,direction) So: rot(@(x,y,z)sin(x-y-3*z),PI,@(2,1)(2,2),@(3,1)(1,-2,3)) rot(@(x,y,z)sin(x-y-3*z),PI,@(2,1)(2,2),@(3,1)(1,-2,3))
Author:
GBEMIRO
  • Constructor Details

    • ROTOR

      public ROTOR(double angle, Direction direction)
      Creates a new object of class ROTOR that can be used to rotate Point objects, Line objects, and Plane objects, Function objects and so on. This constructor defaults the rotor center, i.e the point about which the rotation will occur to zero.
      Parameters:
      angle - The angle of rotation
      direction - The direction in which rotation will occur. When rotation occurs, for a Point object, it occurs in a single plane whose direction vector or direction indices dictate or specify the direction of rotation. For a Line object, it occurs in a multitude of parallel planes which being parallel will have a common direction vector. This direction vector specifies the direction of rotation.
    • ROTOR

      public ROTOR(double angle, Point rotorCenter, Direction direction)
      Creates a new object of class ROTOR that can be used to rotate Point objects, Line objects, and Plane objects, Function objects and so on.
      Parameters:
      angle - The angle of rotation
      rotorCenter - The Point object about which the rotation will occur.
      direction - The direction in which rotation will occur. When rotation occurs, for a Point object, it occurs in a single plane whose direction vector or direction indices dictate or specify the direction of rotation. For a Line object, it occurs in a multitude of parallel planes which being parallel will have a common direction vector. This direction vector specifies the direction of rotation.
  • Method Details

    • getAngle

      public double getAngle()
      Returns:
      the angle of rotation of the object
    • setAngle

      public void setAngle(double angle)
      Parameters:
      angle - sets the angle of rotation
    • setDirection

      public void setDirection(Direction direction)
      The direction indices of rotation. e.g if a body is to be rotated in such a way that a particular point on it will always move in the plane 2x+3y+4z+45=23 Then the direction indices of rotation are 2,3,4. They are stored in a point object.
      Parameters:
      direction - sets the direction indices of rotation These are very important and must be supplied correctly to the system.
    • getDirection

      public Direction getDirection()
      The direction indices of rotation. e.g if a body is to be rotated in such a way that a particular point on it will always move in the plane 2x+3y+4z+45=23 Then the direction indices of rotation are 2,3,4. They are stored in a point object. These are very important and must be supplied correctly to the system.
      Returns:
      the direction indices of rotation
    • getRotorCenter

      public Point getRotorCenter()
      Returns:
      the coordinates of the point about which rotation occurs.
    • setXAxisName

      public void setXAxisName(String name)
      Parameters:
      name - sets the name of the x axis. The default is x.
    • setYAxisName

      public void setYAxisName(String name)
      Parameters:
      name - sets the name of the y axis. The default is y.
    • setZAxisName

      public void setZAxisName(String name)
      Parameters:
      name - sets the name of the z axis. The default is z.
    • getCoordinateAxesName

      public String[] getCoordinateAxesName()
      Returns:
      an array containing the names of all the 3 axes.
    • setRotorCenter

      public void setRotorCenter(Point rotorCenter)
      Parameters:
      rotorCenter - sets the coordinates of the point about which rotation occurs.
    • planarXYRotate

      public static Point planarXYRotate(Point p, Point cen, double angle)
      Method for rotating a Point object in the XY plane or in any plane parallel to the XY plane. The Point object to be rotated and the one about which it is rotating must have the same Z coordinates.
      Parameters:
      p - a Point object in the xy plane The z coordinates of both Point objects must be either the same or must both be zero.
      cen - a Point object about which the rotation of the first Point object will occur.
      angle - the angle of rotation
      Returns:
      a Point object in the xy plane rotated through the angle
    • rotate

      public Point rotate(Point p)
      Parameters:
      p - The Point object to be rotated.
      Returns:
      a Point object that is the new Point object obtained by rotating the Point object parameter through the angle attribute of this ROTOR object and about the Point attribute of this class, i.e (rotorCenter) and also in the given direction.
    • rotate

      public Line3D rotate(Line3D line)
      Parameters:
      line - The Line3D object to be rotated.
      Returns:
      a Line3D object that is the new Line3D object obtained by rotating the Line3D object parameter through the angle attribute of this ROTOR object and about the Point attribute of this class, i.e (rotorCenter) and also in the given direction.
    • rotate

      public Plane rotate(Plane plane)
      Parameters:
      plane - The Plane object to be rotated.
      Returns:
      a Plane object that is the new Plane object obtained by rotating the Plane object parameter through the angle attribute of this ROTOR object and about the Point attribute of this class, i.e (rotorCenter) and also in the given direction.
    • toString

      public String toString()
      Overrides:
      toString in class Object
      Returns:
      the String representation of this object describing its attributes as at when this method was called.
    • rotate

      public String rotate(String function)
      CARE!!! The developer makes no guarantees about what will happen if an invalid function string is passed to this method. This method only works with valid functions that use the names assigned to the coordinate axes(default is x,y,z). Wherever they occur as variables in the expression, they MUST BE ENCLOSED IN CIRCULAR BRACKETS!!! THE VARIABLE NAMES MUST BE SINGLE ALPHABET CHARACTERS ONLY!!!!. No parser or expression analyzer is used before rotating this function, so be warned. IF YOUR FUNCTION WILL CONTAIN METHOD NAMES OR INBUILT FUNCTIONS THAT ARE NOT LISTED IN THE
      invalid reference
      ROTOR#METHODS
      ARRAY, ADD THEM TO THAT ARRAY
      Parameters:
      function - the function string to be rotated.
      Returns:
      the rotated function.
    • transformMathCoordsToJavaCoords

      public static Point transformMathCoordsToJavaCoords(Point point)
      Converts a point in the mathematical xy plane to one in the Java screen coordinates xy plane by rotating the point through PI radians in the direction of the yz plane
      Parameters:
      point - a Point object in the mathematical xy plane
      Returns:
      a Point object in the Java screen xy plane.
    • transformJavaCoordsToMathCoords

      public static Point transformJavaCoordsToMathCoords(Point point)
      Converts a point in the Java screen coordinates xy plane to one in the mathematical xy plane by rotating the point through PI radians in the direction of the yz plane
      Parameters:
      point - a Point object in the Java screen xy plane.
      Returns:
      a Point object in the mathematical xy plane.
    • rotateLine

      public static Line rotateLine(Line line, double ang, Point p)
      Parameters:
      line - The line to be rotated.
      ang - The angle of rotation in rads.
      p - The point about which to rotate this Line object,
      Returns:
      a new Line object after rotating it through theta rads about point, p.
    • rotateRectangle

      public static Polygon rotateRectangle(Rectangle rect, Point orbitalCenter, double angle)
      Rotates a Rectangle object.
      Parameters:
      rect - The Rectangle object to be rotated.
      orbitalCenter - The point about which rotation will occur.
      angle - The angle of rotation.
      Returns:
      a Polygon object being the product of rotation of the Rectangle object.
    • rotatePolygon

      public static Polygon rotatePolygon(Polygon p, Point orbitalCenter, double angle)
    • main

      public static void main(String[] args)
    • main1

      public static void main1(String[] args)