Package net.phys2d.raw.shapes

Examples of net.phys2d.raw.shapes.Line


    Box box = (Box) boxBody.getShape();
    Circle circle = (Circle) circleBody.getShape();
   
    Vector2f[] pts = box.getPoints(boxBody.getPosition(), boxBody.getRotation());
    Line[] lines = new Line[4];
    lines[0] = new Line(pts[0],pts[1]);
    lines[1] = new Line(pts[1],pts[2]);
    lines[2] = new Line(pts[2],pts[3]);
    lines[3] = new Line(pts[3],pts[0]);
   
    float r2 = circle.getRadius() * circle.getRadius();
    int closest = -1;
    float closestDistance = Float.MAX_VALUE;
   
View Full Code Here


      return new Box((float)((com.a.b.b.c)localObject).a(), (float)((com.a.b.b.c)localObject).c());
    }
    if ((paramb instanceof d))
    {
      localObject = (d)paramb;
      return new Line((float)((d)localObject).a(), (float)((d)localObject).c(), (float)((d)localObject).d(), (float)((d)localObject).e());
    }
    throw new IllegalArgumentException("Unsupported form: " + paramb + '.');
  }
View Full Code Here

public class LineCircleCollider
  implements Collider
{
  public strictfp int collide(Contact[] paramArrayOfContact, Body paramBody1, Body paramBody2)
  {
    Line localLine = (Line)paramBody1.getShape();
    Circle localCircle = (Circle)paramBody2.getShape();
    Vector2f[] arrayOfVector2f = localLine.getVertices(paramBody1.getPosition(), paramBody1.getRotation());
    Vector2f localVector2f1 = arrayOfVector2f[0];
    Vector2f localVector2f2 = arrayOfVector2f[1];
    ROVector2f localROVector2f = paramBody2.getPosition();
    Vector2f localVector2f3 = new Vector2f(localVector2f2);
    localVector2f3.sub(localVector2f1);
View Full Code Here

public class LinePolygonCollider extends PolygonPolygonCollider
{
  public int collide(Contact[] paramArrayOfContact, Body paramBody1, Body paramBody2)
  {
    Line localLine = (Line)paramBody1.getShape();
    Polygon localPolygon = (Polygon)paramBody2.getShape();
    Vector2f[] arrayOfVector2f1 = localLine.getVertices(paramBody1.getPosition(), paramBody1.getRotation());
    Vector2f[] arrayOfVector2f2 = localPolygon.getVertices(paramBody2.getPosition(), paramBody2.getRotation());
    Vector2f localVector2f1 = localPolygon.getCentroid(paramBody2.getPosition(), paramBody2.getRotation());
    int i = 0.0F > (localVector2f1.x - arrayOfVector2f1[0].x) * (arrayOfVector2f1[1].y - arrayOfVector2f1[0].y) - (arrayOfVector2f1[1].x - arrayOfVector2f1[0].x) * (localVector2f1.y - arrayOfVector2f1[0].y) ? 1 : 0;
    if (i != 0)
    {
View Full Code Here

    {
      if (i >= paramArrayOfContact.length)
        return paramArrayOfContact.length;
      Vector2f localVector2f2 = arrayOfVector2f[arrayOfInt[j][0]];
      Vector2f localVector2f3 = arrayOfVector2f[((arrayOfInt[j][0] + 1) % arrayOfVector2f.length)];
      Line localLine = new Line(localVector2f2, localVector2f3);
      float f1 = localLine.distanceSquared(paramBody2.getPosition());
      float f2 = localCircle.getRadius() * localCircle.getRadius();
      if (f1 < f2)
      {
        Vector2f localVector2f4 = new Vector2f();
        localLine.getClosestPoint(paramBody2.getPosition(), localVector2f4);
        Vector2f localVector2f5 = new Vector2f(paramBody2.getPosition());
        localVector2f5.sub(localVector2f4);
        float f3 = localCircle.getRadius() - localVector2f5.length();
        localVector2f5.normalise();
        paramArrayOfContact[i].setSeparation(-f3);
View Full Code Here

  }

  public strictfp int collide(Contact[] paramArrayOfContact, Body paramBody1, Body paramBody2)
  {
    int i = 0;
    Line localLine1 = (Line)paramBody1.getShape();
    Box localBox = (Box)paramBody2.getShape();
    Vector2f localVector2f1 = new Vector2f(localLine1.getDX(), localLine1.getDY());
    localVector2f1.normalise();
    Vector2f localVector2f2 = new Vector2f(-localLine1.getDY(), localLine1.getDX());
    localVector2f2.normalise();
    Vector2f localVector2f3 = new Vector2f();
    localLine1.getStart().projectOntoUnit(localVector2f2, localVector2f3);
    float f1 = getProp(localVector2f3, localVector2f2);
    Vector2f localVector2f4 = MathUtil.sub(paramBody2.getPosition(), paramBody1.getPosition());
    localVector2f4.projectOntoUnit(localVector2f2, localVector2f3);
    float f2 = getProp(localVector2f3, localVector2f2);
    Vector2f[] arrayOfVector2f = localBox.getPoints(paramBody2.getPosition(), paramBody2.getRotation());
    float[] arrayOfFloat1 = new float[4];
    float[] arrayOfFloat2 = new float[4];
    int j = 0;
    for (int k = 0; k < 4; k++)
    {
      arrayOfVector2f[k].sub(paramBody1.getPosition());
      arrayOfVector2f[k].projectOntoUnit(localVector2f2, localVector2f3);
      arrayOfFloat1[k] = getProp(localVector2f3, localVector2f2);
      arrayOfVector2f[k].projectOntoUnit(localVector2f1, localVector2f3);
      arrayOfFloat2[k] = getProp(localVector2f3, new Vector2f(localLine1.getDX(), localLine1.getDY()));
      if ((arrayOfFloat2[k] >= 1.0F) || (arrayOfFloat2[k] <= 0.0F))
        j++;
    }
    if (j == 4)
      return 0;
    Vector2f localVector2f5 = new Vector2f(localVector2f2);
    int m;
    Vector2f localVector2f6;
    Line localLine2;
    Line localLine3;
    float f3;
    float f4;
    Vector2f localVector2f7;
    if (f2 < f1)
    {
      if (!localLine1.blocksInnerEdge())
        return 0;
      localVector2f5.scale(-1.0F);
      for (m = 0; m < 4; m++)
        if (arrayOfFloat1[m] > f1)
          if (arrayOfFloat2[m] < 0.0F)
          {
            localVector2f6 = new Vector2f();
            localLine2 = new Line(getPt(arrayOfVector2f, m - 1), arrayOfVector2f[m]);
            localLine3 = new Line(getPt(arrayOfVector2f, m + 1), arrayOfVector2f[m]);
            localLine2.getClosestPoint(localLine1.getStart(), localVector2f3);
            localVector2f3.projectOntoUnit(localVector2f2, localVector2f6);
            f3 = getProp(localVector2f6, localVector2f2);
            localLine3.getClosestPoint(localLine1.getStart(), localVector2f3);
            localVector2f3.projectOntoUnit(localVector2f2, localVector2f6);
            f4 = getProp(localVector2f6, localVector2f2);
            if ((f3 > 0.0F) && (f4 > 0.0F))
            {
              localVector2f7 = new Vector2f(paramBody1.getPosition());
              localVector2f7.add(localLine1.getStart());
              resolveEndPointCollision(localVector2f7, paramBody1, paramBody2, localVector2f5, localLine2, localLine3, paramArrayOfContact[i], m);
              i++;
            }
          }
          else if (arrayOfFloat2[m] > 1.0F)
          {
            localVector2f6 = new Vector2f();
            localLine2 = new Line(getPt(arrayOfVector2f, m - 1), arrayOfVector2f[m]);
            localLine3 = new Line(getPt(arrayOfVector2f, m + 1), arrayOfVector2f[m]);
            localLine2.getClosestPoint(localLine1.getEnd(), localVector2f3);
            localVector2f3.projectOntoUnit(localVector2f2, localVector2f6);
            f3 = getProp(localVector2f6, localVector2f2);
            localLine3.getClosestPoint(localLine1.getEnd(), localVector2f3);
            localVector2f3.projectOntoUnit(localVector2f2, localVector2f6);
            f4 = getProp(localVector2f6, localVector2f2);
            if ((f3 > 0.0F) && (f4 > 0.0F))
            {
              localVector2f7 = new Vector2f(paramBody1.getPosition());
              localVector2f7.add(localLine1.getEnd());
              resolveEndPointCollision(localVector2f7, paramBody1, paramBody2, localVector2f5, localLine2, localLine3, paramArrayOfContact[i], m);
              i++;
            }
          }
          else
          {
            arrayOfVector2f[m].projectOntoUnit(localVector2f1, localVector2f3);
            localVector2f3.add(paramBody1.getPosition());
            paramArrayOfContact[i].setSeparation(-(arrayOfFloat1[m] - f1));
            paramArrayOfContact[i].setPosition(new Vector2f(localVector2f3));
            paramArrayOfContact[i].setNormal(localVector2f5);
            paramArrayOfContact[i].setFeature(new FeaturePair(m));
            i++;
          }
    }
    else
    {
      if (!localLine1.blocksOuterEdge())
        return 0;
      for (m = 0; m < 4; m++)
        if (arrayOfFloat1[m] < f1)
          if (arrayOfFloat2[m] < 0.0F)
          {
            localVector2f6 = new Vector2f();
            localLine2 = new Line(getPt(arrayOfVector2f, m - 1), arrayOfVector2f[m]);
            localLine3 = new Line(getPt(arrayOfVector2f, m + 1), arrayOfVector2f[m]);
            localLine2.getClosestPoint(localLine1.getStart(), localVector2f3);
            localVector2f3.projectOntoUnit(localVector2f2, localVector2f6);
            f3 = getProp(localVector2f6, localVector2f2);
            localLine3.getClosestPoint(localLine1.getStart(), localVector2f3);
            localVector2f3.projectOntoUnit(localVector2f2, localVector2f6);
            f4 = getProp(localVector2f6, localVector2f2);
            if ((f3 < 0.0F) && (f4 < 0.0F))
            {
              localVector2f7 = new Vector2f(paramBody1.getPosition());
              localVector2f7.add(localLine1.getStart());
              resolveEndPointCollision(localVector2f7, paramBody1, paramBody2, localVector2f5, localLine2, localLine3, paramArrayOfContact[i], m);
              i++;
            }
          }
          else if (arrayOfFloat2[m] > 1.0F)
          {
            localVector2f6 = new Vector2f();
            localLine2 = new Line(getPt(arrayOfVector2f, m - 1), arrayOfVector2f[m]);
            localLine3 = new Line(getPt(arrayOfVector2f, m + 1), arrayOfVector2f[m]);
            localLine2.getClosestPoint(localLine1.getEnd(), localVector2f3);
            localVector2f3.projectOntoUnit(localVector2f2, localVector2f6);
            f3 = getProp(localVector2f6, localVector2f2);
            localLine3.getClosestPoint(localLine1.getEnd(), localVector2f3);
            localVector2f3.projectOntoUnit(localVector2f2, localVector2f6);
            f4 = getProp(localVector2f6, localVector2f2);
            if ((f3 < 0.0F) && (f4 < 0.0F))
            {
              localVector2f7 = new Vector2f(paramBody1.getPosition());
View Full Code Here

    Vector2f localVector2f1 = new Vector2f(paramVector2f1);
    Vector2f localVector2f2 = new Vector2f(localVector2f1);
    localVector2f2.add(paramVector2f2);
    paramLine2.move(paramBody1.getPosition());
    paramLine1.move(paramBody1.getPosition());
    Line localLine = new Line(localVector2f1, localVector2f2);
    Vector2f localVector2f3 = localLine.intersect(paramLine2);
    Vector2f localVector2f4 = localLine.intersect(paramLine1);
    float f1 = 3.4028235E+38F;
    if (localVector2f3 != null)
      f1 = localVector2f3.distance(localVector2f1) - paramVector2f2.length();
    float f2 = 3.4028235E+38F;
    if (localVector2f4 != null)
View Full Code Here

      return 0;
    Box localBox = (Box)paramBody1.getShape();
    Circle localCircle = (Circle)paramBody2.getShape();
    Vector2f[] arrayOfVector2f = localBox.getPoints(paramBody1.getPosition(), paramBody1.getRotation());
    Line[] arrayOfLine = new Line[4];
    arrayOfLine[0] = new Line(arrayOfVector2f[0], arrayOfVector2f[1]);
    arrayOfLine[1] = new Line(arrayOfVector2f[1], arrayOfVector2f[2]);
    arrayOfLine[2] = new Line(arrayOfVector2f[2], arrayOfVector2f[3]);
    arrayOfLine[3] = new Line(arrayOfVector2f[3], arrayOfVector2f[0]);
    float f5 = localCircle.getRadius() * localCircle.getRadius();
    int i = -1;
    float f6 = 3.4028235E+38F;
    for (int j = 0; j < 4; j++)
    {
View Full Code Here

TOP

Related Classes of net.phys2d.raw.shapes.Line

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.