示例#1
0
    void OnSetMode(VibrationalMode mode)
    {
        this.VibrationalMode = mode;
        var spectrum           = new float[AppManager.Instance.NumberOfFrequencies];
        var maximumFrequency   = AppManager.Instance.MaximumFrequency;
        var resonanceFrequency = AudioFrequency;

        for (int i = 0; i < spectrum.Length; i++)
        {
            float freq = (1f * i / spectrum.Length) * maximumFrequency;
            spectrum [i] = GaussianScale * Mathf.Exp(-Mathf.Pow(GaussianStrength * (freq - resonanceFrequency), 2));
        }
        ExcitationFrequency = new FrequencyRange(spectrum, 0, maximumFrequency);
    }
示例#2
0
    /// Creates a molecule from a definition. NOTE: Does not actually create it in game, for this then call CreateMoleculeGraphic
    public Molecule CreateMolecule(MoleculeDefinition definition)
    {
        var molecule = new Molecule(definition);

        foreach (var atomDefinition in definition.Atoms)
        {
            var atom = new Atom(molecule, atomDefinition);
            molecule.Atoms.Add(atom);
        }

        foreach (var modeDefinition in definition.VibrationalModes)
        {
            var mode = new VibrationalMode(molecule, modeDefinition);
            molecule.VibrationalModes.Add(mode);
        }

        foreach (var bondDefinition in definition.Bonds)
        {
            var bond = new Bond(molecule, bondDefinition);
            molecule.Bonds.Add(bond);
        }

        return(molecule);
    }