public void Difuse() { var id = (ModelParameters.ModelTypeIndex + rand.Next(ModelRepository.PrototypeCount)) % ModelRepository.PrototypeCount; ModelParameters.ModelTypeIndex = id; var angle = ModelParameters.Angle + rand.Next(-15, +15 + 1); ModelParameters.Angle = (short)angle; var scale = ModelParameters.Scale + rand.Next(-15, +15 + 1); ModelParameters.Scale = (short)scale; ModelParameters = ModelRepository.GetClosestTo(ModelParameters); var template = ModelParameters.TryGetTemplate(); this.updateTemplateData(template); }
public static ModelParticle FromParameters(params double[] arr) { var mParams = new ModelParams(modelTypeIndex: (int)arr[0], scale: (short)arr[1], angle: (short)arr[2]); mParams = ModelRepository.GetClosestTo(mParams); var p = new ModelParticle { ModelParameters = mParams, Weight = 0 }; var template = mParams.TryGetTemplate(); p.updateTemplateData(template); return(p); }