Last active
May 13, 2021 03:32
-
-
Save chuongmep/ed68b78b6072a8865121a5348d5a6a09 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Cross Product Vector | |
/// </summary> | |
/// <param name="vector"></param> | |
/// <param name="other"></param> | |
/// <returns></returns> | |
public static Autodesk.DesignScript.Geometry.Vector Cross(Autodesk.DesignScript.Geometry.Vector vector, | |
Autodesk.DesignScript.Geometry.Vector other) | |
{ | |
var x = vector.Y * other.Z - vector.Z * other.Y; | |
var y = vector.Z * other.X - vector.X * other.Z; | |
var z = vector.X * other.Y - vector.Y * other.X; | |
Autodesk.DesignScript.Geometry.Vector v = Autodesk.DesignScript.Geometry.Vector.ByCoordinates(x, y, z); | |
return v; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Obtains the cross product of two vectors. | |
/// </summary> | |
/// <param name="u">Vector3.</param> | |
/// <param name="v">Vector3.</param> | |
/// <returns>Vector3.</returns> | |
public static XYZ CrossProduct(this XYZ u, XYZ v) | |
{ | |
double a = u.Y * v.Z - u.Z * v.Y; | |
double b = u.Z * v.X - u.X * v.Z; | |
double c = u.X * v.Y - u.Y * v.X; | |
return new XYZ(a, b, c); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment