public Simplex(Tuple <int, Vector <double> >[] edges, RiemannianSpace ambiantSpace) : base(edges) { var directionalVectors = new List <Vector <double> >(); foreach (var item in edges.Skip(1)) { directionalVectors.Add(item.Item2 - BasePoint); } DirectionalVectors = directionalVectors.ToArray(); DimAmbiantSpace = BasePoint.Count(); Parametrization chart = x => { var dir = Matrix <double> .Build.DenseOfColumnVectors(DirectionalVectors); return(dir * x + BasePoint); }; PushForward pushForward = x => { return(Matrix <double> .Build.DenseOfColumnVectors(DirectionalVectors)); }; AmbiantSpace = ambiantSpace; Trivialization = new LocalTrivialization(chart, pushForward, ambiantSpace); }
public MetricTensor PullBack(Parametrization chart, PushForward pushForward) { return(x => { var _pushForward = pushForward(x); var _pushForwardT = pushForward(x).Transpose(); return _pushForwardT * Metric(chart(x)) * _pushForward; }); }
/// <summary>Creates a new <see cref="IGridPointCurve<TLabel>"/> object with respect to a specified curve parametrization. /// </summary> /// <param name="curveParametrization">The curve parametrization.</param> /// <param name="capacity">The number of elements that the new grid point curve can initially store.</param> /// <returns>A <see cref="IGridPointCurve{TLabel}"/> object with respect to a specified curve parametrization.</returns> public static IGridPointCurve <double> Create(Parametrization curveParametrization, int capacity = 20) { if (curveParametrization == null) { throw new ArgumentException(nameof(curveParametrization)); } var parametrization = curveParametrization.Create(); if (parametrization is IDifferentiableRealValuedCurve) { return(new StandardGridPointCurveNoLabels.Differentiable(curveParametrization, parametrization, capacity)); } return(new StandardGridPointCurveNoLabels(curveParametrization, parametrization, capacity)); }
/// <summary>Creates a new read-only <see cref="IGridPointCurve<TLabel>"/> object with respect to a specified curve parametrization. /// </summary> /// <typeparam name="TLabel">The type of the label.</typeparam> /// <param name="curveParametrization">The curve parametrization.</param> /// <param name="gridPointCount">The number of grid points, i.e. the number of relevant elements of <paramref name="gridPointLabels"/>, <paramref name="gridPointArguments"/> and <paramref name="gridPointValues"/> to take into account.</param> /// <param name="gridPointLabels">The labels of the grid points (the reference will be stored only).</param> /// <param name="gridPointArguments">The arguments of the grid points, thus labels of the curve in its <see cref="System.Double"/> representation in ascending order.</param> /// <param name="gridPointValues">The values of the grid points corresponding to <paramref name="gridPointArguments"/>.</param> /// <param name="gridPointArgumentStartIndex">The null-based start index of <paramref name="gridPointArguments"/> and <paramref name="gridPointLabels"/> to take into account.</param> /// <param name="gridPointValueStartIndex">The null-based start index of <paramref name="gridPointValues"/> to take into account.</param> /// <param name="gridPointArgumentIncrement">The increment for <paramref name="gridPointArguments"/> and <paramref name="gridPointLabels"/>.</param> /// <param name="gridPointValueIncrement">The increment for <paramref name="gridPointValues"/>.</param> /// <returns>A read-only <see cref="IGridPointCurve<TLabel>"/> object with respect to the desired interpolation and extrapolation approaches.</returns> /// <remarks>This method is mainly used for two-dimensional surface interpolation. Assuming a large grid point matrix, for example 1.000 x 1.000 and one may apply for example a linear interpolation /// along horizontal direction and afterwards a linear interpolation along vertical direction. Then we create 1.000 curves in horizontal direction, where the (double) labels and values are constant. The /// standard implementation create a copy of 3 * 1.000 x 1.000 = 3.000.000 values and calles the update method of the underlying <see cref="ICurveDataFitting"/> object which again copy 2 * 1.000 * 1.000 = 2.000.000 values, i.e. in total 5 Mio values. /// This implementation takes into account references, the underlying <see cref="ICurveDataFitting"/> implementation should create deep copies of grid point arguments/values only, i.e. 2 Mio double values.</remarks> public static IGridPointCurve <TLabel> Create <TLabel>(Parametrization curveParametrization, int gridPointCount, IList <TLabel> gridPointLabels, IList <double> gridPointArguments, IList <double> gridPointValues, int gridPointArgumentStartIndex = 0, int gridPointValueStartIndex = 0, int gridPointArgumentIncrement = 1, int gridPointValueIncrement = 1) where TLabel : IEquatable <TLabel> { if (curveParametrization == null) { throw new ArgumentException(nameof(curveParametrization)); } var parametrization = curveParametrization.Create(); if (parametrization is IDifferentiableRealValuedCurve) { return(new SmartReadOnlyGridPointCurve <TLabel> .Differentiable(parametrization, gridPointCount, gridPointLabels, gridPointArguments, gridPointValues, gridPointArgumentStartIndex, gridPointValueStartIndex, gridPointArgumentIncrement, gridPointValueIncrement)); } return(new SmartReadOnlyGridPointCurve <TLabel>(parametrization, gridPointCount, gridPointLabels, gridPointArguments, gridPointValues, gridPointArgumentStartIndex, gridPointValueStartIndex, gridPointArgumentIncrement, gridPointValueIncrement)); }
// Use this for initialization void Start() { param = new Parametrization(); param.Initialize(); //param.SetExpr1("(cos(u)+sin(v))*sin(w)+cos(t)"); //param.SetExpr2("(cos(v)+sin(u))*sin(w)+cos(t)"); //param.SetExpr3("cos(w)+sin(t)"); param.SetExpr1("w*sin(u)*cos(v)+cos(t*15)*0.3"); param.SetExpr2("w*cos(u)*cos(v)+cos(t*15)*0.3"); param.SetExpr3("w*sin(v)"); param.AddParameter("u"); param.SetParameterMin("u", "0"); param.SetParameterMax("u", "pi"); param.AddParameter("v"); param.SetParameterMin("v", "0"); param.SetParameterMax("v", "2*pi"); param.AddParameter("w"); param.SetParameterMin("w", "0"); param.SetParameterMax("w", "5"); param.AddParameter("t"); param.SetParameterMin("t", "0"); param.SetParameterMax("t", "2*pi"); param.SetupSolver(); param.SetupSamples(); List <Vector3> positions = param.Evaluate(); particles = new ParticleSystem.Particle[positions.Count]; for (int i = 0; i < positions.Count; i++) { particles[i].position = positions[i]; particles[i].startSize = 0.05f; particles[i].startColor = Color.cyan; } shuriken = GetComponent <ParticleSystem>(); shuriken.SetParticles(particles, positions.Count); Debug.Log(shuriken.particleCount); }
public LocalTrivialization(Parametrization chart, PushForward pushForward, RiemannianSpace chartDomain) : base(chartDomain.Dim, chartDomain.Metric) { LocalMetric = PullBack(chart, pushForward); }
/// <summary> /// Curve length parametrization. Returns the accumulated "distances" /// between the points (x(i),y(i)) and (x(i+1),y(i+1)) in t(i+1) /// for i = lo ... hi. t(lo) = 0.0 always. /// </summary> /// <param name="x">The vector of abscissa values.</param> /// <param name="y">The vector of ordinate values.</param> /// <param name="t">Output: the vector of "distances".</param> /// <param name="parametrization">The parametrization rule to apply.</param> /// <remarks><code> /// The way of parametrization is controlled by the parameter parametrization. /// Parametrizes curve length using: /// /// |dx| + |dy| if parametrization = Norm1 /// sqrt(dx^2+dy^2) if parametrization = Norm2 /// (dx^2+dy^2) if parametrization = SqrNorm2 /// /// Parametrization using Norm2 usually gives the best results. /// </code></remarks> public virtual void Parametrize (IROVector x, IROVector y, IVector t, Parametrization parametrization) { int lo = x.LowerBound, hi = x.UpperBound, i; switch (parametrization) { case Parametrization.Norm1: for (i = lo+1, t[lo] = 0.0; i <= hi; i++) t[i] = t[i-1] + Math.Abs(x[i]-x[i-1]) + Math.Abs(y[i]-y[i-1]); break; case Parametrization.Norm2: for (i = lo+1, t[lo] = 0.0; i <= hi; i++) t[i] = t[i-1] + RMath.Hypot( x[i]-x[i-1],y[i]-y[i-1] ); break; case Parametrization.SqrNorm2: for (i = lo+1, t[lo] = 0.0; i <= hi; i++) t[i] = t[i-1] + sqr(x[i]-x[i-1]) + sqr(y[i]-y[i-1]); break; default: throw new System.ArgumentException("illegal value for parametrization method"); } }
public static GenCtxProperty MutateParametrize(Parametrization p, GCXF <float> mutater) => new ParametrizationProp(p, mutater);
public static GenCtxProperty Parametrize(Parametrization p) => new ParametrizationProp(p, null);