亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? coordinate.java

?? 這是我模仿window自帶的小游戲掃雷編的,很簡單,只實現了掃雷的基本功能,現拿出來與大家分享!
?? JAVA
字號:
package edu.harvard.syrah.nc;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;

import java.util.Vector;

/*
 * NCLib - a network coordinate library
 * 
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation; either version 2 of the License.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details (
 * see the LICENSE file ).
 * 
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 * Place, Suite 330, Boston, MA 02111-1307 USA
 */

/**
 * A coordinate in the Euclidian space.
 * 
 * @author Michael Parker, Jonathan Ledlie
 */
public class Coordinate {

	final static protected int CLASS_HASH = Coordinate.class.hashCode();

	final protected double[] coords;
  final protected byte version;
  final protected int num_dims;

  public static double MIN_COORD = 0.1;
  
    public byte getVersion () {
	return version;
    }
  
	/**
	 * Creates a copy of this <code>Coordinate</code> object, such that
	 * updates in this coordinate are not reflected in the returned object.
	 * 
	 * @return a copy of these coordinates
	 */
	public Coordinate makeCopy() {
		return new Coordinate(coords, true);
	}
	
	/**
	 * Creates a new coordinate having a position at the origin.
	 * 
	 * @param num_dimensions
	 * the number of coordinate dimensions
	 */
	public Coordinate(int num_dimensions) {
		coords = new double[num_dimensions];
    version = VivaldiClient.CURRENT_VERSION;
    if (VivaldiClient.USE_HEIGHT) num_dimensions--;
    num_dims = num_dimensions;
	}

	/**
	 * 
	 * @param num_dimensions
	 * @param dis
	 * @throws IOException
	 */


	public Coordinate(int num_dimensions, DataInputStream dis) throws IOException {  
	  coords = new double[num_dimensions];
	  version = dis.readByte();
	  for (int i = 0; i < num_dimensions; i++) {
	    coords[i] = ((double) dis.readFloat());
	  }
    if (VivaldiClient.USE_HEIGHT) num_dimensions--;
    num_dims = num_dimensions;
    
	}

  public void toSerialized(DataOutputStream dos) throws IOException {
    final int num_dims = coords.length;
    dos.writeByte (version);
    for (int i = 0; i < num_dims; ++i) {
      // when writing, cast to float
      dos.writeFloat((float) coords[i]);
    }
    //if (VivaldiClient.USE_HEIGHT) dos.writeFloat((float) coords[num_dims]);
  }
  
	protected Coordinate(Coordinate c) {
		this(c.coords, true);
	}

	/**
	 * Creates a new coordinate having a position specified by the array
	 * <code>init_coords</code>. The number of dimensions is this equal to
	 * the array length.
	 * 
	 * @param init_pos
	 * the position for this coordinate
	 * @param make_copy
	 * whether a copy of the array should be made
	 */
	protected Coordinate(double[] init_pos, boolean make_copy) {
    int _num_dims = init_pos.length;
    if (make_copy) {
			coords = new double[_num_dims];
			System.arraycopy(init_pos, 0, coords, 0, _num_dims);
		}
		else {
			coords = init_pos;
		}
    version = VivaldiClient.CURRENT_VERSION;
    if (VivaldiClient.USE_HEIGHT) _num_dims--;
    num_dims = _num_dims;
	}

	/**
	 * Creates a new coordinate having a position specified by the array
	 * <code>init_coords</code>. The number of dimensions is this equal to
	 * the array length.
	 * 
	 * @param init_pos
	 * the position for this coordinate
	 */
	public Coordinate(float[] init_pos) {
		int _num_dims = init_pos.length;
		coords = new double[_num_dims];
		for (int i = 0; i < _num_dims; ++i) {
			coords[i] = init_pos[i];
		}
    version = VivaldiClient.CURRENT_VERSION;
    if (VivaldiClient.USE_HEIGHT) _num_dims--;
    num_dims = _num_dims;
	}

  public boolean isCompatible (Coordinate _other) {
    if (version == _other.version)
      return true;
    return false;
  }
  
	public void bump () {
	  for (int i = 0; i < coords.length; ++i) {
	    if (Math.abs(coords[i]) < MIN_COORD) {
        double length = VivaldiClient.random.nextDouble()+MIN_COORD;
	      // don't set height to be negative, if we are using it
        if ( (!VivaldiClient.USE_HEIGHT || i < coords.length-1) &&
          (VivaldiClient.random.nextBoolean())) {
          length *= -1.;
	      }
	      coords[i] += length;
	    }
	  }
	}




	/**
	 * Returns the number of dimensions this coordinate has.
	 * 
	 * @return the number of coordinate dimensions.
	 */
	public int getNumDimensions() {
		return coords.length;
	}

	/**
	 * Returns the Euclidian distance to the given coordinate parameter.
	 * 
	 * @param c
	 * the coordinate to find the Euclidian distance to
	 * @return the distance to parameter <code>c</code>
	 */
  public double distanceToNonOriginCoord(Coordinate c) {
    if (atOrigin() || c.atOrigin()) return Double.NaN;
    return distanceTo(c);
  }
  
  public double distanceTo(Coordinate c) {
    //System.err.println("us="+this.toString()+" them="+c.toString());
    if (!isCompatible(c)) return Double.NaN;
    if (!isValid() || !c.isValid()) return Double.NaN;
    
    // used for debugging so we can call distanceTo on something null
    assert ((VivaldiClient.USE_HEIGHT && num_dims == coords.length-1) ||
            (!VivaldiClient.USE_HEIGHT && num_dims == coords.length));

    if (c == null) {
      assert (!VivaldiClient.SIMULATION);
      return -1.;
    }
    double sum = 0.0;
    for (int i = 0; i < num_dims; ++i) {
      final double abs_dist = coords[i] - c.coords[i];
      sum += (abs_dist * abs_dist);
    }
    sum = Math.sqrt(sum);
    if (VivaldiClient.USE_HEIGHT && sum > 0) {
      sum = sum + coords[coords.length-1] + c.coords[coords.length-1];
    }
    return sum;
  }

	// Same regardless of using height
	public void add(Vec v) {
		final int num_dims = coords.length;
		for (int i = 0; i < num_dims; ++i) {
			coords[i] += v.direction[i];
		}
	}

	/*
	 * protected method, do not expose to client
	 */
  protected Vec getDirection(Coordinate c) {
    double length = distanceTo(c);
    if (length == 0) return null;
    final Vec new_vec = new Vec(coords.length);
    for (int i = 0; i < num_dims; ++i) {
      new_vec.direction[i] = (c.coords[i] - coords[i])/length;
    }
    if (VivaldiClient.USE_HEIGHT) {
      new_vec.direction[coords.length-1] = 
        (c.coords[coords.length-1] + coords[coords.length-1])/length;
    }
    return new_vec;
  }

  protected boolean assign (Coordinate c) {
    if (coords.length != c.coords.length) return false;
    for (int i = 0; i < coords.length; ++i) {
      coords[i] = c.coords[i];
    }
    return true;
  }
  
  public void checkHeight () {
    if (!VivaldiClient.USE_HEIGHT) return;
    if (coords[coords.length-1] <= MIN_COORD) {
      coords[coords.length-1] = VivaldiClient.random.nextDouble()+MIN_COORD;
    }
  }
  
  public boolean atOrigin () {
    for (int i = 0; i < coords.length; i++) {
      if (coords[i] != 0)
        return false;
    }
    return true;
  }
  
	public Vec asVectorFromZero(boolean make_copy) {
		return new Vec(coords, make_copy);
	}

	public boolean isValid() {
	  final double NEG_MAX_DIST_FROM_ORIGIN = -1 * VivaldiClient.MAX_DIST_FROM_ORIGIN;
		for (int i = 0; i < coords.length; ++i) {
			if (Double.isNaN(coords[i])) {
        if (VivaldiClient.SIMULATION) System.err.println("coord isNaN i="+i);
				return false;
			}
			if (coords[i] > VivaldiClient.MAX_DIST_FROM_ORIGIN ||
			    coords[i] < NEG_MAX_DIST_FROM_ORIGIN) {
        if (VivaldiClient.SIMULATION) System.err.println("coord too far from origin i="+i+" coord="+coords[i]);
			    return false;
			}
		}
    if (VivaldiClient.USE_HEIGHT && coords[coords.length-1] < 0) return false;
		return true;
	}

	protected void reset() {
		for (int i = 0; i < coords.length; ++i) {
			coords[i] = 0.;
		}
	}

	public boolean equals(Object obj) {
		if (obj instanceof Coordinate) {
			Coordinate c = (Coordinate) obj;
			final int num_dims = coords.length;
			for (int i = 0; i < num_dims; ++i) {
				if (coords[i] != c.coords[i]) {
					return false;
				}
			}
			return true;
		}
		return false;
	}

	public int hashCode() {
		final int num_dims = coords.length;
		int hc = CLASS_HASH;
		for (int i = 0; i < num_dims; ++i) {
			hc ^= new Double(coords[i]).hashCode();
		}
		return hc;
	}

	public String toString() {
		final StringBuffer sbuf = new StringBuffer(1024);
		sbuf.append("[");

		final int num_dims = coords.length;
		for (int i = 0; true;) {
      if (i == num_dims-1 && VivaldiClient.USE_HEIGHT) {
        sbuf.append('h');  
      }
      sbuf.append(VivaldiClient.nf.format(coords[i]));
      if (++i < num_dims) {
				sbuf.append(",");
			}
			else {
				break;
			}
		}
		sbuf.append("]");
		return sbuf.toString();
	}

	public String toStringAsVector() {
		final StringBuffer sbuf = new StringBuffer(1024);

		for (int i = 0; i < coords.length; i++) {
      if (i == coords.length - 1 && VivaldiClient.USE_HEIGHT)
        sbuf.append('h');
      sbuf.append(VivaldiClient.nf.format(coords[i]));
      if (i != coords.length - 1)
				sbuf.append(" ");
		}
		return sbuf.toString();
	}

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲综合在线视频| 精品一二三四在线| 日本一道高清亚洲日美韩| 国产ts人妖一区二区| 欧美系列在线观看| 国产性色一区二区| 久久国产精品色婷婷| 欧美图片一区二区三区| 欧美国产精品v| 久久99久久99精品免视看婷婷| 色综合久久99| 国产清纯在线一区二区www| 日韩电影一区二区三区| 欧美亚洲国产一区二区三区| 亚洲欧美中日韩| 高清不卡在线观看| 亚洲精品一区二区三区影院| 日韩av在线播放中文字幕| 色综合激情五月| 国产精品成人一区二区三区夜夜夜| 久久99国产精品久久99| 欧美一区二区三区四区高清| 亚洲成av人影院| 欧美日韩免费不卡视频一区二区三区 | 91精品国产美女浴室洗澡无遮挡| 久久99国产精品久久99| 欧美久久久久久久久| 亚洲三级在线看| 91老司机福利 在线| 亚洲欧美一区二区三区孕妇| 高清国产一区二区| 中文字幕亚洲区| 成人sese在线| 中文字幕在线不卡视频| 不卡一二三区首页| 亚洲精品一二三| 日本精品视频一区二区| 悠悠色在线精品| 欧美日韩一区二区三区高清| 亚洲成人自拍网| 欧美精品日韩精品| 久久国产综合精品| 久久久精品欧美丰满| 粉嫩aⅴ一区二区三区四区| 中文字幕va一区二区三区| 不卡高清视频专区| 亚洲va欧美va天堂v国产综合| 欧洲av在线精品| 日本va欧美va精品| 国产日韩欧美高清在线| 成人av电影在线| 一区2区3区在线看| 欧美二区乱c少妇| 国产综合久久久久久久久久久久| 国产欧美一区二区三区鸳鸯浴 | 久久久国产一区二区三区四区小说 | 亚洲一线二线三线视频| 9191久久久久久久久久久| 久久国产综合精品| 亚洲摸摸操操av| 91精品国产综合久久精品| 韩国女主播一区二区三区| 亚洲婷婷国产精品电影人久久| 在线观看日韩av先锋影音电影院| 日韩黄色小视频| 国产欧美一区二区精品性色超碰 | 日韩一区二区三免费高清| 国产一区二区三区精品欧美日韩一区二区三区 | 蜜臀av一区二区在线免费观看| 欧美成人午夜电影| 色域天天综合网| 另类中文字幕网| 国产乱码一区二区三区| 中文字幕一区二区三区精华液| 在线亚洲免费视频| 国产在线视视频有精品| 一区二区三区日韩精品视频| 精品久久国产字幕高潮| 99久久久国产精品| 人禽交欧美网站| 亚洲日本va午夜在线电影| 欧美一区三区二区| 一本色道久久综合亚洲aⅴ蜜桃 | 久久影院午夜论| 欧美日韩中文一区| 成人激情动漫在线观看| 亚洲成av人片一区二区梦乃| 国产精品久久777777| 日韩一级精品视频在线观看| 色94色欧美sute亚洲13| 国产精品亚洲午夜一区二区三区 | 日韩一区二区免费在线观看| 91网站黄www| 丁香激情综合五月| 久久99精品久久久久久动态图 | 欧美日韩免费视频| 色综合咪咪久久| 不卡的看片网站| 国产99久久久国产精品潘金| 美女精品一区二区| 日韩经典一区二区| 亚洲chinese男男1069| 一区二区在线观看视频在线观看| 日韩午夜中文字幕| 日韩一区二区精品葵司在线| 欧洲精品视频在线观看| 91久久精品午夜一区二区| 粉嫩在线一区二区三区视频| 韩国v欧美v日本v亚洲v| 蜜臀久久99精品久久久久宅男| 亚洲国产精品麻豆| 亚洲一区二区在线视频| 亚洲欧美一区二区三区极速播放| 日韩精品中文字幕在线不卡尤物| 欧美日韩亚洲综合在线 | 亚洲成人综合视频| 亚洲与欧洲av电影| 一区二区欧美在线观看| 伊人色综合久久天天| 亚洲v日本v欧美v久久精品| 亚洲国产一二三| 在线免费不卡视频| 日本久久电影网| 欧美亚洲国产怡红院影院| 欧美日韩国产一区| 337p亚洲精品色噜噜噜| 欧美一区二区三区在| 精品理论电影在线观看| 国产亚洲成aⅴ人片在线观看| 亚洲国产岛国毛片在线| 亚洲欧洲日韩综合一区二区| 亚洲你懂的在线视频| 亚洲二区视频在线| 日本成人在线网站| 美腿丝袜亚洲色图| 成人免费看黄yyy456| 色综合久久综合网97色综合| 欧美日韩中文字幕一区| 日韩视频在线你懂得| 久久精品这里都是精品| 日韩美女视频一区二区| 亚洲午夜一区二区三区| 精品在线免费观看| av激情亚洲男人天堂| 欧美日韩精品三区| 国产日韩影视精品| 亚洲少妇30p| 日韩成人精品在线观看| 成人蜜臀av电影| 欧美日韩成人综合天天影院| 亚洲精品在线网站| 一区二区欧美视频| 国产在线视频一区二区| 欧美制服丝袜第一页| 久久你懂得1024| 亚洲国产日韩在线一区模特| 国产综合久久久久影院| 欧美日韩一区小说| 欧美国产精品一区二区三区| 视频精品一区二区| 99视频在线精品| 日韩三级电影网址| 亚洲黄色小视频| 激情偷乱视频一区二区三区| 欧美亚洲一区二区三区四区| 国产精品天美传媒沈樵| 日韩vs国产vs欧美| 色www精品视频在线观看| 国产欧美一区二区三区在线看蜜臀 | 精品在线视频一区| 欧美午夜不卡视频| 中文字幕在线观看不卡视频| 国产麻豆视频一区二区| 91精品国产综合久久久久| 国产精品传媒入口麻豆| 国产精品中文字幕一区二区三区| 欧美三区免费完整视频在线观看| 免费欧美日韩国产三级电影| 91在线你懂得| 中文字幕av资源一区| 国产美女主播视频一区| 日韩精品专区在线影院重磅| 日韩综合在线视频| 欧美色精品天天在线观看视频| 自拍偷在线精品自拍偷无码专区| 久久 天天综合| 精品久久久网站| 免费成人你懂的| 欧美一级日韩不卡播放免费| 亚洲.国产.中文慕字在线| 色婷婷激情久久| 亚洲激情av在线| 色久优优欧美色久优优| 国产精品不卡在线| 成人app在线| 专区另类欧美日韩| 欧美在线一二三| 午夜精品福利久久久| 欧美精品久久天天躁| 亚洲超碰精品一区二区|