123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- using System;
- using System.Collections.Generic;
- namespace WingAIDiagnosisService.Carotid.CarotidInterFacesData
- {
- public struct Vector3I
- {
- public int X;
- public int Y;
- public int Z;
- public Vector3I(int x, int y, int z)
- {
- X = x;
- Y = y;
- Z = z;
- }
- }
- public struct Vector3F
- {
- public float X;
- public float Y;
- public float Z;
- }
- public struct Vector3D : IEquatable<Vector3D>
- {
- private const float Precision = 0.000001f;
- public double X;
- public double Y;
- public double Z;
- public Vector3D(double x, double y, double z)
- {
- X = x;
- Y = y;
- Z = z;
- }
- public bool Equals(Vector3D other)
- {
- if (Math.Abs(X - other.X) < Precision && Math.Abs(Y - other.Y) < Precision &&
- Math.Abs(Z - other.Z) < Precision)
- {
- return true;
- }
- return false;
- }
- public override bool Equals(object obj)
- {
- if (ReferenceEquals(null, obj)) return false;
- return obj is Vector3D && Equals((Vector3D) obj);
- }
- public override int GetHashCode()
- {
- unchecked
- {
- var hashCode = X.GetHashCode();
- hashCode = (hashCode * 397) ^ Y.GetHashCode();
- hashCode = (hashCode * 397) ^ Z.GetHashCode();
- return hashCode;
- }
- }
- /// <summary>
- /// Judge two vector is parallel.
- /// </summary>
- /// <param name="v2">other vector</param>
- /// <returns>True indicate parallel, otherwise false.</returns>
- public bool IsParallel(Vector3D v2)
- {
- //判断是否平行(x,y,z)与(a,b,c)平行的条件。 xb - ya=0,xc - za = 0, yc - zb = 0
- var a1 = X * v2.Y - Y * v2.X;
- var a2 = X * v2.Z - Z * v2.X;
- var a3 = Y * v2.Z - Z * v2.Y;
- return Math.Abs(a1) < Precision && Math.Abs(a2) < Precision && Math.Abs(a3) < Precision;
- }
- /// <summary>
- /// Subtracts v2 from this vector.
- /// </summary>
- /// <param name="v2">vector v2.</param>
- public void Sub(Vector3D v2)
- {
- X -= v2.X;
- Y -= v2.Y;
- Z -= v2.Z;
- }
- /// <summary>
- /// Get a new vector (a - b);
- /// </summary>
- public static Vector3D SubVectors(Vector3D a, Vector3D b)
- {
- return new Vector3D(a.X - b.X, a.Y - b.Y, a.Z - b.Z);
- }
- }
- public struct Vector2
- {
- public double X;
- public double Y;
- public Vector2(double x, double y)
- {
- X = x;
- Y = y;
- }
- }
- public struct Vector2I
- {
- public int X;
- public int Y;
- public Vector2I(int x, int y)
- {
- X = x;
- Y = y;
- }
- }
- public class ClipPlaneData
- {
- //Error code.
- public int ErrorCode { get; }
- /// <summary>
- /// Get Vector3 points.
- /// </summary>
- public IEnumerable<Vector3D> WorldPoints { get; }
- /// <summary>
- /// Get Vector2 points.
- /// </summary>
- public IEnumerable<Vector2> ImagePoints { get; }
- /// <summary>
- /// Get Image data.
- /// </summary>
- public string ImageData { get; }
- public ClipPlaneData(IEnumerable<Vector3D> worldPoints, IEnumerable<Vector2> imagePoints, string imageData, int errorCode)
- {
- WorldPoints = worldPoints;
- ImagePoints = imagePoints;
- ImageData = imageData;
- ErrorCode = errorCode;
- }
- }
- public class ClipPlanePoints
- {
- //Error code.
- public int ErrorCode { get; }
- /// <summary>
- /// Get Vector3 points.
- /// </summary>
- public IEnumerable<Vector3D> WorldPoints { get; }
- public ClipPlanePoints(IEnumerable<Vector3D> worldPoints, int errorCode)
- {
- WorldPoints = worldPoints;
- ErrorCode = errorCode;
- }
- }
- }
|