コード例 #1
0
ファイル: Path.cs プロジェクト: johtela/Compose3D
        public static Path <V, D> FromPie(float radiusX, float radiusY, float startAngle, float endAngle,
                                          int nodeCount)
        {
            if (radiusY <= 0f || radiusY <= 0f)
            {
                throw new ArgumentException("Radiuses have to be greater than zero.");
            }
            if (startAngle == endAngle)
            {
                endAngle += FMath.TwoPi;
            }
            var stepAngle = (endAngle - startAngle) / (nodeCount - 1);
            var nodes     = new V[nodeCount];
            var angle     = startAngle;

            for (var i = 0; i < nodeCount; i++)
            {
                var pos = Vec.FromArray <D, float> (
                    radiusX * (float)Math.Cos(angle), radiusY * (float)Math.Sin(angle), 0f, 0f);
                nodes [i] = new V()
                {
                    position = pos
                };
                angle = angle + stepAngle;
            }
            return(new Path <V, D> (nodes));
        }
コード例 #2
0
ファイル: ColorMap.cs プロジェクト: johtela/Compose3D
 public static ColorMap <V> GrayScale()
 {
     return(new ColorMap <V> {
         { 0f, Vec.FromArray <V, float> (0f, 0f, 0f, 1f) },
         { 1f, Vec.FromArray <V, float> (1f, 1f, 1f, 1f) }
     });
 }
コード例 #3
0
ファイル: Path.cs プロジェクト: johtela/Compose3D
        public static Path <V, D> FromRectangle(float width, float height)
        {
            var halfX = width / 2f;
            var halfY = height / 2f;

            return(FromVecs(
                       Vec.FromArray <D, float> (-halfX, -halfY),
                       Vec.FromArray <D, float> (-halfX, halfY),
                       Vec.FromArray <D, float> (halfX, halfY),
                       Vec.FromArray <D, float> (halfX, -halfY)).Close());
        }
コード例 #4
0
        public static Arbitrary <V> ArbitraryVec <V, T> (int size)
            where V : struct, IVec <V, T>
            where T : struct, IEquatable <T>
        {
            var arb = Arbitrary.Get <T> ();

            return(new Arbitrary <V> (
                       from a in arb.Generate.FixedArrayOf(size)
                       select Vec.FromArray <V, T> (a),
                       v => from a in v.ToArray <V, T> ().Map(arb.Shrink).Combinations()
                       select Vec.FromArray <V, T> (a)));
        }
コード例 #5
0
ファイル: VecTests.cs プロジェクト: johtela/ComposeFX
 public void CheckMultiplyWithVector <V> () where V : struct, IVec <V, float>
 {
     (from vec in Prop.ForAll <V> ()
      from scalar in Prop.ForAll <float> ()
      let len = vec.Length
                let scaleVec = Vec.FromArray <V, float> (scalar.Duplicate(vec.Dimensions))
                               let scaled = vec.Multiply(scaleVec)
                                            let len_scaled = scaled.Length
                                                             let scalar_x_len = FMath.Abs(scaleVec[0] * len)
                                                                                select new { vec, scaleVec, len, scaled, len_scaled, scalar_x_len })
     .Check(p => p.len_scaled.ApproxEquals(p.scalar_x_len),
            label: $"{typeof (V).Name}: | vec * scale | = scale.x * | vec | when scale is uniform");
 }
コード例 #6
0
        public void CheckMultiplyWithVector <V> () where V : struct, IVec <V, float>
        {
            var prop = from vec in Prop.Choose <V> ()
                       from scalar in Prop.Choose <float> ()
                       let len = vec.Length
                                 let scaleVec = Vec.FromArray <V, float> (scalar.Duplicate(vec.Dimensions))
                                                let scaled = vec.Multiply(scaleVec)
                                                             let len_scaled = scaled.Length
                                                                              let scalar_x_len = FMath.Abs(scaleVec[0] * len)
                                                                                                 select new { vec, scaleVec, len, scaled, len_scaled, scalar_x_len };

            prop.Label("{0}: | vec * scale | = scale.x * | vec | when scale.xyzw are equal", typeof(V).Name)
            .Check(p => p.len_scaled.ApproxEquals(p.scalar_x_len));
        }
コード例 #7
0
ファイル: VertexColor.cs プロジェクト: johtela/Compose3D
 public static IVertexColor <V> RGB(float red, float green, float blue)
 {
     return(new VertColor(Vec.FromArray <V, float> (red, green, blue, 1f)));
 }