/* * $Id$ * This file is a part of the Arakhne Foundation Classes, http://www.arakhne.org/afc * * Copyright (c) 2000-2012 Stephane GALLAND. * Copyright (c) 2005-10, Multiagent Team, Laboratoire Systemes et Transports, * Universite de Technologie de Belfort-Montbeliard. * Copyright (c) 2013-2016 The original authors, and other authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.arakhne.afc.math.discrete.object2d; import org.arakhne.afc.math.generic.Point2D; import org.arakhne.afc.math.generic.Tuple2D; import org.arakhne.afc.math.generic.Vector2D; /** 2D Point with 2 integers. * * @author $Author: sgalland$ * @version $FullVersion$ * @mavengroupid $GroupId$ * @mavenartifactid $ArtifactId$ * @deprecated see {@link org.arakhne.afc.math.geometry.d2.i.Point2i} */ @Deprecated @SuppressWarnings("all") public class Point2i extends Tuple2i<Point2D> implements Point2D { private static final long serialVersionUID = 6087683508168847436L; /** */ public Point2i() { // } /** * @param tuple is the tuple to copy. */ public Point2i(Tuple2D<?> tuple) { super(tuple); } /** * @param tuple is the tuple to copy. */ public Point2i(int[] tuple) { super(tuple); } /** * @param tuple is the tuple to copy. */ public Point2i(float[] tuple) { super(tuple); } /** * @param x * @param y */ public Point2i(int x, int y) { super(x,y); } /** * @param x * @param y */ public Point2i(float x, float y) { super(x,y); } /** * @param x * @param y */ public Point2i(double x, double y) { super((float)x,(float)y); } /** * @param x * @param y */ public Point2i(long x, long y) { super(x,y); } /** {@inheritDoc} */ @Override public Point2i clone() { return (Point2i)super.clone(); } /** * {@inheritDoc} */ @Override public float distanceSquared(Point2D p1) { float dx, dy; dx = this.x-p1.getX(); dy = this.y-p1.getY(); return (dx*dx+dy*dy); } /** * {@inheritDoc} */ @Override public float distance(Point2D p1) { float dx, dy; dx = this.x-p1.getX(); dy = this.y-p1.getY(); return (float)Math.sqrt(dx*dx+dy*dy); } /** * {@inheritDoc} */ @Override public float distanceL1(Point2D p1) { return (Math.abs(this.x-p1.getX()) + Math.abs(this.y-p1.getY())); } /** * {@inheritDoc} */ @Override public float distanceLinf(Point2D p1) { return (Math.max( Math.abs(this.x-p1.getX()), Math.abs(this.y-p1.getY()))); } @Override public void add(Point2D t1, Vector2D t2) { this.x = (int)(t1.getX() + t2.getX()); this.y = (int)(t1.getY() + t2.getY()); } @Override public void add(Vector2D t1, Point2D t2) { this.x = (int)(t1.getX() + t2.getX()); this.y = (int)(t1.getY() + t2.getY()); } @Override public void add(Vector2D t1) { this.x = (int)(this.x + t1.getX()); this.y = (int)(this.y + t1.getY()); } @Override public void scaleAdd(int s, Vector2D t1, Point2D t2) { this.x = (int)(s * t1.getX() + t2.getX()); this.y = (int)(s * t1.getY() + t2.getY()); } @Override public void scaleAdd(float s, Vector2D t1, Point2D t2) { this.x = (int)(s * t1.getX() + t2.getX()); this.y = (int)(s * t1.getY() + t2.getY()); } @Override public void scaleAdd(int s, Point2D t1, Vector2D t2) { this.x = (int)(s * t1.getX() + t2.getX()); this.y = (int)(s * t1.getY() + t2.getY()); } @Override public void scaleAdd(float s, Point2D t1, Vector2D t2) { this.x = (int)(s * t1.getX() + t2.getX()); this.y = (int)(s * t1.getY() + t2.getY()); } @Override public void scaleAdd(int s, Vector2D t1) { this.x = (int)(s * this.x + t1.getX()); this.y = (int)(s * this.y + t1.getY()); } @Override public void scaleAdd(float s, Vector2D t1) { this.x = (int)(s * this.x + t1.getX()); this.y = (int)(s * this.y + t1.getY()); } @Override public void sub(Point2D t1, Vector2D t2) { this.x = (int)(t1.getX() - t1.getX()); this.y = (int)(t1.getY() - t1.getY()); } @Override public void sub(Vector2D t1) { this.x = (int)(this.x - t1.getX()); this.y = (int)(this.y - t1.getY()); } }