public Frustum () { for (int i = 0; i < 6; i++) { planes[i] = new Plane(new Vector3(), 0); } }
/** Constructs a new plane out of the three given points that are considered to be on the plane. The normal is calculated via a * cross product between (point1-point2)x(point2-point3) * * @param point1 The first point * @param point2 The second point * @param point3 The third point */ public Plane (Vector3 point1, Vector3 point2, Vector3 point3) { set(point1, point2, point3); }
/** Intersects a {@link Ray} and a {@link Plane}. The intersection point is stored in intersection in case an intersection is * present. * * @param ray The ray * @param plane The plane * @param intersection The vector the intersection point is written to (optional) * @return Whether an intersection is present. */ public static boolean intersectRayPlane (Ray ray, Plane plane, Vector3 intersection) { float denom = ray.direction.dot(plane.getNormal()); if (denom != 0) { float t = -(ray.origin.dot(plane.getNormal()) + plane.getD()) / denom; if (t < 0) return false; if (intersection != null) intersection.set(ray.origin).add(v0.set(ray.direction).scl(t)); return true; } else if (plane.testPoint(ray.origin) == Plane.PlaneSide.OnPlane) { if (intersection != null) intersection.set(ray.origin); return true; } else return false; }
public static boolean intersectSegmentPlane (Vector3 start, Vector3 end, Plane plane, Vector3 intersection) { Vector3 dir = v0.set(end).sub(start); float denom = dir.dot(plane.getNormal()); if (denom == 0f) return false; float t = -(start.dot(plane.getNormal()) + plane.getD()) / denom; if (t < 0 || t > 1) return false; intersection.set(start).add(dir.scl(t)); return true; }
/** Returns whether the point is in the frustum. * * @param point The point * @return Whether the point is in the frustum. */ public boolean pointInFrustum (Vector3 point) { for (int i = 0; i < planes.length; i++) { PlaneSide result = planes[i].testPoint(point); if (result == PlaneSide.Back) return false; } return true; }
SimpleMaterial localSimpleMaterial = new SimpleMaterial(); Bitmap localBitmap = BitmapFactory.decodeResource(this.mContext.getResources(), R.drawable.image); localSimpleMaterial.addTexture(this.mTextureManager.addTexture(localBitmap)); Plane localPlane = new Plane(10.0F, 10.0F, 1, 1); localPlane.setRotZ(-90.0F); localPlane.setScale(3.7F); localPlane.setPosition(0.0F, 0.0F, 10.0F); localPlane.setMaterial(localSimpleMaterial); addChild(localPlane);
public class fooTest { private Plane plane; @Mock private Car car; @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); plane = new Plane(); plane.setId(2); plane.setColor(Color.BLUE); Mockito.when(car.findById(eq(plane.getId()))).thenReturn(plane); } @Test public void isBlue() { // There is no point in testing car since the result is already mocked. Plane result = car.findById(2); assertEquals(Color.BLUE, result.getColor()); } }
setSceneCachingEnabled(true); final Plane projectionScreen = new Plane(PLANE_WIDTH, PLANE_HEIGHT, 64, 64); final Material material = new Material(); material.setColor(0); projectionScreen.setDoubleSided(true); projectionScreen.setMaterial(material); projectionScreen.setTransparent(true); projectionScreen.setPosition(0, 0, PLANE_DISTANCE); getCurrentScene().addChild(projectionScreen);
Bitmap texture = BitmapFactory.decodeResource(this.mContext.getResources(), ResourceId); planeMat.addTexture(this.mTextureManager.addTexture(texture)); Plane plane = new Plane(1.0f, 1.0f, 1, 1); plane.setRotZ(-90.0f); //plane.setScale(2.8f); plane.setMaterial(planeMat); addChild(plane);
public static void main(String args []){ List<PlaneSeat> seats = new ArrayList<>(); for(int i =10;i>0;i--) seats.add(new PlaneSeat(i--)); Plane plane = new Plane(); plane.setSeats(seats); System.out.println(plane);//print before sorting plane.sortByCustomers(); System.out.println(plane);//after sorting by customer }
/** Returns whether the point is in the frustum. * * @param x The X coordinate of the point * @param y The Y coordinate of the point * @param z The Z coordinate of the point * @return Whether the point is in the frustum. */ public boolean pointInFrustum (float x, float y, float z) { for (int i = 0; i < planes.length; i++) { PlaneSide result = planes[i].testPoint(x, y, z); if (result == PlaneSide.Back) return false; } return true; }
public static boolean intersectSegmentPlane (Vector3 start, Vector3 end, Plane plane, Vector3 intersection) { Vector3 dir = v0.set(end).sub(start); float denom = dir.dot(plane.getNormal()); if (denom == 0f) return false; float t = -(start.dot(plane.getNormal()) + plane.getD()) / denom; if (t < 0 || t > 1) return false; intersection.set(start).add(dir.scl(t)); return true; }
public Frustum () { for (int i = 0; i < 6; i++) { planes[i] = new Plane(new Vector3(), 0); } }
/** Intersects a {@link Ray} and a {@link Plane}. The intersection point is stored in intersection in case an intersection is * present. * * @param ray The ray * @param plane The plane * @param intersection The vector the intersection point is written to (optional) * @return Whether an intersection is present. */ public static boolean intersectRayPlane (Ray ray, Plane plane, Vector3 intersection) { float denom = ray.direction.dot(plane.getNormal()); if (denom != 0) { float t = -(ray.origin.dot(plane.getNormal()) + plane.getD()) / denom; if (t < 0) return false; if (intersection != null) intersection.set(ray.origin).add(v0.set(ray.direction).scl(t)); return true; } else if (plane.testPoint(ray.origin) == Plane.PlaneSide.OnPlane) { if (intersection != null) intersection.set(ray.origin); return true; } else return false; }
/** Returns whether the point is in the frustum. * * @param point The point * @return Whether the point is in the frustum. */ public boolean pointInFrustum (Vector3 point) { for (int i = 0; i < planes.length; i++) { PlaneSide result = planes[i].testPoint(point); if (result == PlaneSide.Back) return false; } return true; }
/** Constructs a new plane out of the three given points that are considered to be on the plane. The normal is calculated via a * cross product between (point1-point2)x(point2-point3) * * @param point1 The first point * @param point2 The second point * @param point3 The third point */ public Plane (Vector3 point1, Vector3 point2, Vector3 point3) { set(point1, point2, point3); }