Skip to content

Fix #232 and #235 #239

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Expression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ private SpecialValue TryCreateSV(String name, Term[] p)

double[] dp = GetParamsAsT<double>(p, pCount);
var q = UnityEngine.Quaternion.LookRotation(VesselUtils.GetNorthVector(executionContext.Vessel), executionContext.Vessel.upAxis);
q *= UnityEngine.Quaternion.Euler(new UnityEngine.Vector3((float)-dp[0], (float)dp[1], (float)(dp.Count() > 2 ? dp[2] : 0)));
q *= UnityEngine.Quaternion.Euler(new UnityEngine.Vector3((float)-dp[1], (float)dp[0], (float)(dp.Count() > 2 ? dp[2] : 0)));

return new Direction(q);
}
Expand Down
2 changes: 1 addition & 1 deletion ExpressionTerm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ private void processSymbols()
if (String.IsNullOrEmpty(Text)) return;

// HEADING.. BY is now deprecated in favor of HEADING(x,y), but here it is if you're using it still
Text = Regex.Replace(Text, "HEADING ([ :@A-Za-z0-9\\.\\-\\+\\*/]+) BY ([ :@A-Za-z0-9\\.\\-\\+\\*/]+)", "HEADING($2,$1)", RegexOptions.IgnoreCase);
Text = Regex.Replace(Text, "HEADING ([ :@A-Za-z0-9\\.\\-\\+\\*/]+) BY ([ :@A-Za-z0-9\\.\\-\\+\\*/]+)", "HEADING($1,$2)", RegexOptions.IgnoreCase);

// Resource tags are now deprecated in favor of SHIP:ResourceName
Text = Regex.Replace(Text, "(\\s|^)<([a-zA-Z]+)>(\\s|$)", " SHIP:$2 ", RegexOptions.IgnoreCase);
Expand Down
8 changes: 8 additions & 0 deletions Vector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ public static explicit operator Direction(Vector d)
public static Vector operator *(Vector a, Vector b) { return new Vector(a.x * b.x, a.y * b.y, a.z * b.z); }
public static Vector operator *(Vector a, float b) { return new Vector(a.x * b, a.y * b, a.z * b); }
public static Vector operator *(Vector a, double b) { return new Vector(a.x * b, a.y * b, a.z * b); }
public static Vector operator /(Vector a, Vector b) { return new Vector(a.x / b.x, a.y / b.y, a.z / b.z); }
public static Vector operator /(Vector a, float b) { return new Vector(a.x / b, a.y / b, a.z / b); }
public static Vector operator /(Vector a, double b) { return new Vector(a.x / b, a.y / b, a.z / b); }
public static Vector operator +(Vector a, Vector b) { return new Vector(a.ToVector3D() + b.ToVector3D()); }
public static Vector operator -(Vector a, Vector b) { return new Vector(a.ToVector3D() - b.ToVector3D()); }

Expand All @@ -117,6 +120,11 @@ public override object TryOperation(string op, object other, bool reverseOrder)
if (other is Vector) return this * (Vector)other;
if (other is double) return this * (double)other;
}
else if (op == "/")
{
if (other is Vector) return this / (Vector)other;
if (other is double) return this / (double)other;
}
else if (op == "-")
{
if (!reverseOrder)
Expand Down