Example #1
0
    void CreateNegativeVector(string existingVectorName, string newVectorName)
    {
        bool vectorNamesMatch = newVectorName == existingVectorName;

        if (vectorNamesMatch)                   // a = -a
        {
            MakeVectorNegative(existingVectorName);
            return;
        }


        // b = -a

        SuperVector a = GetVectorByName(existingVectorName); // Does a exist?

        if (a == null)                                       // No
        {
            return;                                          // Get out. We can't do anything if we don't have a vector to clone.
        }
        RemoveNamedVector(newVectorName);                    // Removes "b" if it exists.

        SuperVector b = a.Clone(newVectorName);              // Let's clone "a" and assign it to b

        b.Negative();                                        // Let's negate "b" (flip it)
        AddNamedVector(b);                                   // Let's add the ne
    }
Example #2
0
    void MakeVectorNegative(string vectorName)
    {
        SuperVector matchingVector = GetVectorByName(vectorName);

        if (matchingVector == null)
        {
            return;
        }

        matchingVector.Negative();
    }