Exemplo n.º 1
0
 /// <summary>
 /// Constructs rkd-tree from points and kd-tree data.
 /// </summary>
 public static PointRkdTreeF <V3f[], V3f> ToKdTree(this V3f[] points, PointRkdTreeFData data)
 => new PointRkdTreeF <V3f[], V3f>(
     3, points.Length, points,
     (xs, i) => xs[(int)i], (v, i) => (float)v[i],
     (a, b) => V3f.Distance(a, b), (i, a, b) => b - a,
     (a, b, c) => VecFun.DistanceToLine(a, b, c), VecFun.Lerp, 1e-6f,
     data
     );
        /// <summary>PointRkdTreeDData -> byte[]</summary>
        public static byte[] PointRkdTreeFDataToBuffer(PointRkdTreeFData data)
        {
            if (data == null)
            {
                return(null);
            }
            var ms = new MemoryStream();

            using (var coder = new BinaryWritingCoder(ms))
            {
                object x = data; coder.Code(ref x);
            }
            return(ms.ToArray());
        }