private void InitializeUV(Domain1d uDomain, Domain1d vDomain) { U = new Grid1d(uDomain); U.TopLevelGridChange += TopLevelGridChange; V = new Grid1d(vDomain); V.TopLevelGridChange += TopLevelGridChange; }
/// <summary> /// Construct a color scale with a discrete number of color bands /// </summary> /// <param name="colors">The color scale's key values.</param> /// <param name="colorCount">The number of colors in the final color scale /// These values will be interpolated between the provided colors.</param> public ColorScale(List <Color> colors, int colorCount) { if (colors.Count > colorCount) { throw new ArgumentException("The color scale could not be created. The number of supplied colors is greater than the final color count."); } this.Discrete = true; var numDomains = (double)(colorCount); var colorDomains = new Domain1d(0, 1).DivideByCount(colors.Count - 1).ToList(); for (int i = 0; i < numDomains; i += 1) { var domain = new Domain1d((i / numDomains), (i + 1) / numDomains); var value = i < numDomains / 2 ? domain.Min : domain.Max; var colorDomainIdx = GetDomainIndex(colorDomains, value); if (colorDomainIdx == null) { throw new Exception("The color scale could not be created. An internal calculation error has occurred."); } var foundColorDomainIdx = (int)colorDomainIdx; var foundColorDomain = colorDomains[foundColorDomainIdx]; var tween = (value - foundColorDomain.Min) / foundColorDomain.Length; var color = colors[foundColorDomainIdx].Lerp(colors[foundColorDomainIdx + 1], tween); this.Colors.Add(color); } }
/// <summary> /// Create a ColorScale from a list of colors. The scale will automatically have a domain from 0 to 1. /// </summary> /// <param name="colors"></param> public ColorScale(List <Color> colors) { this.Colors = colors; var domain = new Domain1d(0, 1); this.Domains = domain.DivideByCount(colors.Count - 1).ToList(); }
private void InitializeUV(Domain1d uDomain, Domain1d vDomain) { U = new Grid1d(uDomain); U.SetParent(this); V = new Grid1d(vDomain); V.SetParent(this); }
/// <summary> /// Construct a 1D Grid from another 1D Grid /// </summary> /// <param name="other"></param> public Grid1d(Grid1d other) { this.curve = other.curve; this.curveDomain = other.curveDomain; this.Domain = other.Domain; if (other.Cells != null) { this.Cells = other.Cells.Select(c => new Grid1d(c)).ToList(); } this.Type = other.Type; }
/// <summary> /// Construct a Grid2d using another Grid2d as the base, but with different Grid1ds as its axes. /// </summary> /// <param name="other">The Grid2d to base this one on.</param> /// <param name="u">The Grid1d representing the U Axis.</param> /// <param name="v">The Grid1d representing the V Axis.</param> public Grid2d(Grid2d other, Grid1d u, Grid1d v) { this.U = u; this.U.SetParent(this); this.UDomainInternal = other.UDomainInternal; this.V = v; this.V.SetParent(this); this.VDomainInternal = other.VDomainInternal; this.Type = other.Type; this.boundariesInGridSpace = other.boundariesInGridSpace; this.fromGrid = other.fromGrid; this.toGrid = other.toGrid; }
/// <summary> /// Construct a Grid2d from another Grid2d /// </summary> /// <param name="other"></param> public Grid2d(Grid2d other) { this.U = new Grid1d(other.U); this.U.SetParent(this); this.UDomainInternal = other.UDomainInternal; this.V = new Grid1d(other.V); this.V.SetParent(this); this.VDomainInternal = other.VDomainInternal; this.Type = other.Type; this.boundariesInGridSpace = other.boundariesInGridSpace; this.fromGrid = other.fromGrid; this.toGrid = other.toGrid; if (!other.IsSingleCell) { this.Cells = new List <List <Grid2d> >( other.Cells.Select( col => col.Select( cell => new Grid2d(cell)).ToList() ).ToList()); } }
public Grid2d(Transform fromGrid, Transform toGrid, Domain1d uDomainInternal, Domain1d vDomainInternal, List <Polygon> boundariesInGridSpace, Grid1d u, Grid1d v, string type, List <IndexedCell> modifiedChildCells) { this.fromGrid = fromGrid; this.toGrid = toGrid; this.UDomainInternal = uDomainInternal; this.VDomainInternal = uDomainInternal; this.boundariesInGridSpace = boundariesInGridSpace; this.U = u; this.V = v; this.Type = type; this.U.SetParent(this); this.V.SetParent(this); if (modifiedChildCells != null) { this.cells = GetTopLevelCells(); foreach (var c in modifiedChildCells) { this.Cells[c.I][c.J] = c.Grid; } } }
/// <summary> /// Construct a 1D grid from a numerical domain. The geometry will be assumed to lie along the X axis. /// </summary> /// <param name="domain">The 1-dimensional domain for the grid extents.</param> public Grid1d(Domain1d domain) { Domain = domain; curve = new Line(new Vector3(domain.Min, 0, 0), new Vector3(Domain.Max, 0, 0)); curveDomain = domain; }
/// <summary> /// This constructor is only for internal use by subdivision / split methods. /// </summary> /// <param name="curve">The entire curve of the parent grid</param> /// <param name="domain">The domain of the new subdivided segment</param> /// <param name="curveDomain">The entire domain of the parent grid's curve</param> private Grid1d(Curve curve, Domain1d domain, Domain1d curveDomain) { this.curve = curve; this.curveDomain = curveDomain; Domain = domain; }
/// <summary> /// Construct a 1D grid from a curve. /// </summary> /// <param name="curve">The curve from which to generate the grid.</param> public Grid1d(Curve curve) { this.curve = curve; Domain = new Domain1d(0, curve.Length()); curveDomain = Domain; }
/// <summary> /// Construct a 2d grid with two 1d domains /// </summary> /// <param name="uDomain">The domain along the U axis</param> /// <param name="vDomain">The domain along the V axis</param> private Grid2d(Domain1d uDomain, Domain1d vDomain) { InitializeUV(uDomain, vDomain); }