riej / lsl

Linden Script (LSL) language plugin for IntelliJ IDEA
MIT License
7 stars 2 forks source link

Multiplication and division of vector by rotation is marked as an invalid expression #1

Closed mewore closed 1 year ago

mewore commented 1 year ago

Seen in version 0.1.9.

Example:

// 45-degree rotation around the Z (up) axis
rotation r = llEuler2Rot(<0, 0, 45> * DEG_TO_RAD);

// Vector whose direction is 1 meter to the east
vector v = <1, 0, 0>;

// Vector whose direction is north-east
vector rotated = v * r; // <0.707107, 0.707107, 0.000000>

// Vector whose direction is south-east
// (division performs a rotation in the opposite direction)
vector rotated2 = v / r; // <0.707107, -0.707107, 0.000000>

default {
}

As shown in IntelliJ IDEA: vector-by-rotation

The wiki says it should work; the same code snippet is there: https://wiki.secondlife.com/wiki/Category:LSL_Vector#Rotation

mewore commented 1 year ago

I failed to get the project to run, but I guess adding this in LslPrimitiveType will fix it:

        // <1, 0, 0> * llEuler2Rot(<0, 0, 45> * DEG_TO_RAD) == <0.707107, 0.707107, 0>
        // <1, 0, 0> / llEuler2Rot(<0, 0, 45> * DEG_TO_RAD) == <0.707107, -0.707107, 0>
        if ((operation == LslTypes.MULTIPLE || operation == LslTypes.MULTIPLE_ASSIGN || operation == LslTypes.DIVIDE || operation == LslTypes.DIVIDE_ASSIGN) && this == VECTOR && other == QUATERNION) {
            return VECTOR
        }
mewore commented 1 year ago

I failed to get the project to run I managed to run it by updating org.jetbrains.intellij from 1.8.0 to 1.13.3! I don't know what the root cause was, but it worked. For the record, the error was:

'org.jetbrains.intellij.tasks.IntelliJInstrumentCodeTask' property 'compilerClassPathFromMaven' doesn't have a configured value

Looks like the fix worked: fixed

riej commented 1 year ago

Thank you very much!

mewore commented 1 year ago

\:D