⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sparsegridportrayal3d.java

📁 MASON代表多主体邻里或网络仿真(Multi-Agent Simulator of Neighborhoods or Networks)。它是乔治梅森大学用Java开发的离散事件多主体仿真核心库
💻 JAVA
字号:
package sim.portrayal3d.grid;import javax.vecmath.*;import com.sun.j3d.utils.picking.*;import sim.portrayal.*;import sim.field.grid.*;import sim.portrayal3d.*;import sim.util.*;/** * Portrays both SparseGrid2D and SparseGrid3D fields.  A (0,0) or (0,0,0) object is centered * on the origin.  2D fields are spread through the XY plane and are presumed to have Z=0. *  * @author Gabriel Balan */public class SparseGridPortrayal3D extends SparseFieldPortrayal3D    {    /*      public Transform3D getDefaultTransform()      {      // adjust so that the [0,0,0] object is centered on the origin      return new Transform3D(new Quat4f(), new Vector3d(-0.5,-0.5,-0.5), 1);      }    */        /**     * @see sim.portrayal.SparseFieldPortrayal3D#getLocationOfObjectAsVector3d(Object)     */    public Vector3d getLocationOfObjectAsVector3d(Object obj, Vector3d putInHere)        {        if(field instanceof SparseGrid3D)            {            Int3D locationI3d = ((SparseGrid3D)field).getObjectLocation(obj);            putInHere.x = locationI3d.x;            putInHere.y = locationI3d.y;            putInHere.z = locationI3d.z;            }        else            {            Int2D locationI2d = ((SparseGrid2D)field).getObjectLocation(obj);            putInHere.x = locationI2d.x;            putInHere.y = locationI2d.y;            putInHere.z = 0;            }        return putInHere;        }    public void setField(Object field)        {        dirtyField = true;        if (field instanceof SparseGrid3D || field instanceof SparseGrid2D) this.field = field;        else throw new RuntimeException("Invalid field for SparseGridPortrayal3D: " + field);        }            public LocationWrapper completedWrapper(LocationWrapper w, PickIntersection pi, PickResult pr)             {        return new LocationWrapper( w.getObject(), null , this)  // don't care about location            {            public Object getLocation()                {                if(field instanceof SparseGrid3D)                    return ((SparseGrid3D)field).getObjectLocation(object);                else                    return ((SparseGrid2D)field).getObjectLocation(object);                }                            public String getLocationName()                {                if(field instanceof SparseGrid3D)                    return ((SparseGrid3D)field).getObjectLocation(object).toCoordinates();                else                    return ((SparseGrid2D)field).getObjectLocation(object).toCoordinates();                }            };        }    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -