public override Point3d getRandomBirthPlace(Libutility util) { /*Point3d retpos = emitter.getRandEmitPos(); * double u; * double v; * _srf.ClosestPoint(retpos, out u, out v); * return _srf.PointAt(u, v);*/ return(emitter.getRandEmitPos()); }
public override Point3d getRandomBirthPlace(Libutility util) { /*Point3d retpos = emitter.getRandEmitPos(); double u; double v; _srf.ClosestPoint(retpos, out u, out v); return _srf.PointAt(u, v);*/ return emitter.getRandEmitPos(); }
public override float getOffsetTrailValue(int x, int y, int z, Vector3d orient, float viewangle, float offsetangle, float offsetsteps, Libutility util) { /*Point3d pt; Vector3d[] vec; _srf.Evaluate((x + 0.5) * u_interval, (y + 0.5) * v_interval, 1, out pt, out vec); vec[0].Unitize(); Vector3d oricopy = new Vector3d(orient.X, orient.Y, orient.Z); oricopy.Unitize(); double dotproduc = Vector3d.Multiply(vec[0], oricopy); if (dotproduc > 0.3) return -1; Point3d _origin = uv_positions[x, y, z]; Plane oriplane = new Plane(_origin, orient); float _u = offsetsteps * util.sinlut[(int)viewangle] * util.coslut[(int)offsetangle]; float _v = offsetsteps * util.sinlut[(int)viewangle] * util.sinlut[(int)offsetangle]; float _w = offsetsteps * util.coslut[(int)viewangle]; Point3d target = oriplane.PointAt(_u, _v, _w); Point3d targetid = getIndexByPosition(target.X, target.Y, target.Z); int tx = (int)targetid.X; int ty = (int)targetid.Y; int tz = getWIndex(target.Z); if (tx < 0 || tx >= u || ty < 0 || ty >= v || tz < 0 || tz >= w) return -1; return trail[tx, ty, tz];*/ float viewRad = viewangle * 3.1416F / 180; Point3d _ori = new Point3d(x, y, 0); Vector3d _tarOri = orient; _tarOri.Transform(Transform.Rotation(viewRad, Plane.WorldXY.ZAxis, _ori)); _tarOri.Unitize(); _tarOri *= offsetsteps; Point3d _tar = _ori + _tarOri; //Point3d _tar = Point3d.Add(_ori, _tarOri); int tx = (int)_tar.X; int ty = (int)_tar.Y; if (tx < 0 || tx >= u || ty < 0 || ty >= v) return -1; return trail[tx, ty, 0]; }
public override Point3d getNeighbourhoodFreePosByIndex(int x, int y, int z, int radius, Libutility util) { Point3d retpt = new Point3d(-1, -1, -1); if (radius < 1) { return retpt; } int start_x = x - radius > 0 ? x - radius : 0; int start_y = y - radius > 0 ? y - radius : 0; int start_z = z - radius > 0 ? z - radius : 0; int end_x = x + radius < u ? x + radius : u - 1; int end_y = y + radius < v ? y + radius : v - 1; int end_z = z + radius < w ? z + radius : w - 1; int count = (end_x - start_x + 1) * (end_y - start_y + 1) * (end_z - start_z + 1); // //int[] ids = new int[count]; List<Point3d> freePos = new List<Point3d>(); for (int i = end_x; i >= start_x; i--) { for (int j = end_y; j >= start_y; j--) { //for (int k = end_z; k >= start_z; k--) //{ if (particle_ids[i, j, 0] == -1) { //retpt = new Point3d(i, j, k); freePos.Add(uv_positions[i, j, 0]); //return retpt; } //} } } int lens = freePos.Count; if (lens == 0) return retpt; retpt = freePos[util.getRand(lens)]; return retpt; }
//public abstract void setBirthPlace(List<Point3d> origin); public abstract Point3d getRandomBirthPlace(Libutility util);
public abstract Point3d getNeighbourhoodFreePosByIndex(int u, int v, int w, int radius, Libutility util);//by index
public abstract float getOffsetTrailValue(int u, int v, int w, Vector3d orient, float viewangle, float offsetangle, float offsetsteps, Libutility util);
public override Point3d getNeighbourhoodFreePosByIndex(int x, int y, int z, int radius, Libutility util) { Point3d retpt = new Point3d(-1, -1, -1); if (radius < 1) { return(retpt); } int start_x = x - radius > 0 ? x - radius : 0; int start_y = y - radius > 0 ? y - radius : 0; int start_z = z - radius > 0 ? z - radius : 0; int end_x = x + radius < u ? x + radius : u - 1; int end_y = y + radius < v ? y + radius : v - 1; int end_z = z + radius < w ? z + radius : w - 1; int count = (end_x - start_x + 1) * (end_y - start_y + 1) * (end_z - start_z + 1); // //int[] ids = new int[count]; List <Point3d> freePos = new List <Point3d>(); for (int i = end_x; i >= start_x; i--) { for (int j = end_y; j >= start_y; j--) { //for (int k = end_z; k >= start_z; k--) //{ if (particle_ids[i, j, 0] == -1) { //retpt = new Point3d(i, j, k); freePos.Add(uv_positions[i, j, 0]); //return retpt; } //} } } int lens = freePos.Count; if (lens == 0) { return(retpt); } retpt = freePos[util.getRand(lens)]; return(retpt); }
public override float getOffsetTrailValue(int x, int y, int z, Vector3d orient, float viewangle, float offsetangle, float offsetsteps, Libutility util) { /*Point3d pt; * Vector3d[] vec; * _srf.Evaluate((x + 0.5) * u_interval, (y + 0.5) * v_interval, 1, out pt, out vec); * vec[0].Unitize(); * Vector3d oricopy = new Vector3d(orient.X, orient.Y, orient.Z); * oricopy.Unitize(); * double dotproduc = Vector3d.Multiply(vec[0], oricopy); * if (dotproduc > 0.3) * return -1; * Point3d _origin = uv_positions[x, y, z]; * Plane oriplane = new Plane(_origin, orient); * float _u = offsetsteps * util.sinlut[(int)viewangle] * util.coslut[(int)offsetangle]; * float _v = offsetsteps * util.sinlut[(int)viewangle] * util.sinlut[(int)offsetangle]; * float _w = offsetsteps * util.coslut[(int)viewangle]; * Point3d target = oriplane.PointAt(_u, _v, _w); * Point3d targetid = getIndexByPosition(target.X, target.Y, target.Z); * int tx = (int)targetid.X; * int ty = (int)targetid.Y; * int tz = getWIndex(target.Z); * if (tx < 0 || tx >= u || ty < 0 || ty >= v || tz < 0 || tz >= w) * return -1; * return trail[tx, ty, tz];*/ float viewRad = viewangle * 3.1416F / 180; Point3d _ori = new Point3d(x, y, 0); Vector3d _tarOri = orient; _tarOri.Transform(Transform.Rotation(viewRad, Plane.WorldXY.ZAxis, _ori)); _tarOri.Unitize(); _tarOri *= offsetsteps; Point3d _tar = _ori + _tarOri; //Point3d _tar = Point3d.Add(_ori, _tarOri); int tx = (int)_tar.X; int ty = (int)_tar.Y; if (tx < 0 || tx >= u || ty < 0 || ty >= v) { return(-1); } return(trail[tx, ty, 0]); }
/*public override void setBirthPlace(List<Point3d> origin) * { * _origins = origin; * //foreach (Point3d pt in origin) * //{ * // setGridCellValueByIndex((int) pt.X, (int) pt.Y, (int) pt.Z, 1, 1); * //} * }*/ public override Point3d getRandomBirthPlace(Libutility util) { //int length = _origins.Count; return(emitter.getRandEmitPos()); //return _origins[util.getRand(length)]; }
/* * public trailInfo getOffsetTrailValue(int x, int y, int z, Vector3d orient, float viewangle, float offsetangle, float offsetsteps, Libutility util) * { * Point3f origin = new Point3f(x, y, z); * Plane oriplane = new Plane(origin, orient); * float u = offsetsteps * util.sinlut[(int) viewangle] * util.coslut[(int) offsetangle]; * float v = offsetsteps * util.sinlut[(int) viewangle] * util.sinlut[(int) offsetangle]; * float w = offsetsteps * util.coslut[(int) viewangle]; * Point3d target = oriplane.PointAt(u, v, w); * int tx = (int) Math.Round(target.X); * int ty = (int) Math.Round(target.Y); * int tz = (int) Math.Round(target.Z); * float tr = 0; * if (tx < 0 || tx >= _x || ty < 0 || ty >= _y || tz < 0 || tz >= _z) * tr = -1; * else * tr = trail[tx, ty, tz]; * trailInfo newinfo = new trailInfo(new Point3d(tx, ty, tz), tr); * return newinfo; * }*/ public override Point3d getNeighbourhoodFreePosByIndex(int x, int y, int z, int radius, Libutility util) { Point3d retpt = new Point3d(-1, -1, -1); if (radius < 1) { return(retpt); } /* * int times = 0; * int tpz; * int tpy; * int tpx; * do * { * tpx = util.getRand(x - radius, x + radius + 1); * tpy = util.getRand(y - radius, y + radius + 1); * tpz = util.getRand(z - radius, z + radius + 1); * times++; * } * while (particle_ids[tpx, tpy, tpz] != -1 && times < 20); * if (particle_ids[tpx, tpy, tpz] != -1) * return retpt; * else * return new Point3d(tpx, tpy, tpz); */ int start_x = x - radius > 0 ? x - radius : 0; int start_y = y - radius > 0 ? y - radius : 0; int start_z = z - radius > 0 ? z - radius : 0; int end_x = x + radius < u ? x + radius : u - 1; int end_y = y + radius < v ? y + radius : v - 1; int end_z = z + radius < w ? z + radius : w - 1; int count = (end_x - start_x + 1) * (end_y - start_y + 1) * (end_z - start_z + 1); // //int[] ids = new int[count]; List <Point3d> freePos = new List <Point3d>(); for (int i = end_x; i >= start_x; i--) { for (int j = end_y; j >= start_y; j--) { for (int k = end_z; k >= start_z; k--) { if (particle_ids[i, j, k] == -1) { //retpt = new Point3d(i, j, k); freePos.Add(positions[i, j, k]); //return retpt; } } } } int lens = freePos.Count; if (lens == 0) { return(retpt); } retpt = freePos[util.getRand(lens)]; return(retpt); }
public override float getOffsetTrailValue(int x, int y, int z, Vector3d orient, float viewangle, float offsetangle, float offsetsteps, Libutility util) { //Point3f origin = new Point3f(x, y, z); Point3d _origin = positions[x, y, z]; Plane oriplane = new Plane(_origin, orient); float _u = offsetsteps * util.sinlut[(int)viewangle] * util.coslut[(int)offsetangle]; float _v = offsetsteps * util.sinlut[(int)viewangle] * util.sinlut[(int)offsetangle]; float _w = offsetsteps * util.coslut[(int)viewangle]; //float u = (double) offsetsteps * Math.Sin((double) viewangle * 3.1416F / 180) * Math.Cos((double) offsetangle * 3.1416F / 180); //float v = (double)offsetsteps * Math.Sin((double) viewangle * 3.1416F / 180) * Math.Sin((double) offsetangle * 3.1416F / 180); //float w = (double)offsetsteps * Math.Cos((double) viewangle * 3.1416F / 180); Point3d target = oriplane.PointAt(_u, _v, _w); //int tx = (int)Math.Round(target.X); //int ty = (int)Math.Round(target.Y); //int tz = (int)Math.Round(target.Z); int tx = getUIndex(target.X); int ty = getVIndex(target.Y); int tz = getWIndex(target.Z); if (tx < 0 || tx >= u || ty < 0 || ty >= v || tz < 0 || tz >= w) { return(-1); } return(trail[tx, ty, tz]); }