// // (C) Copyright 2003-2019 by Autodesk, Inc. // // Permission to use, copy, modify, and distribute this software in // object code form for any purpose and without fee is hereby granted, // provided that the above copyright notice appears in all copies and // that both that copyright notice and the limited warranty and // restricted rights notice below appear in all supporting // documentation. // // AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS. // AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF // MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC. // DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE // UNINTERRUPTED OR ERROR FREE. // // Use, duplication, or disclosure by the U.S. Government is subject to // restrictions set forth in FAR 52.227-19 (Commercial Computer // Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) // (Rights in Technical Data and Computer Software), as applicable. // using System; using System.Collections.Generic; using System.Text; using Autodesk.Revit.DB; namespace Revit.SDK.Samples.CurtainSystem.CS.Utility { /// /// Vector4 is a homogeneous coordinate class used to store vector /// and contain method to handle the vector /// public class Vector4 { #region Class member variables and properties private double m_x; private double m_y; private double m_z; private double m_w = 1.0d; /// /// X property to get/set x value of Vector4 /// public double X { get { return m_x; } set { m_x = value; } } /// /// Y property to get/set y value of Vector4 /// public double Y { get { return m_y; } set { m_y = value; } } /// /// Z property to get/set z value of Vector4 /// public double Z { get { return m_z; } set { m_z = value; } } /// /// W property to get/set fourth value of Vector4 /// public double W { get { return m_w; } set { m_w = value; } } #endregion /// /// constructor /// public Vector4(double x, double y, double z) { this.X = x; this.Y = y; this.Z = z; } /// /// constructor, transfer Autodesk.Revit.DB.XYZ to vector /// /// Autodesk.Revit.DB.XYZ structure which needs to be transfered public Vector4(Autodesk.Revit.DB.XYZ v) { this.X = (double)v.X; this.Y = (double)v.Y; this.Z = (double)v.Z; } /// /// get normal vector of plane contains two vectors /// /// second vector /// normal vector of two vectors public Vector4 CrossProduct(Vector4 v) { return new Vector4(this.Y * v.Z - this.Z * v.Y, this.Z * v.X - this.X * v.Z, this.X * v.Y - this.Y * v.X); } /// /// get normal vector of two vectors /// /// first vector /// second vector /// normal vector of two vectors public static Vector4 CrossProduct(Vector4 va, Vector4 vb) { return new Vector4(va.Y * vb.Z - va.Z * vb.Y, va.Z * vb.X - va.X * vb.Z, va.X * vb.Y - va.Y * vb.X); } }; }