Example #1
0
        public void TriangleDoesentExistIsFalse()
        {
            TriangleTest result = new TriangleTest();

            Assert.AreEqual(true, result.Triangle(0, 0, 0));
        }
Example #2
0
        public void OneSideBiggerThanSumOfTwoIsFalse()
        {
            TriangleTest result = new TriangleTest();

            Assert.AreEqual(true, result.Triangle(2, 2, 6));
        }
Example #3
0
        public void OneSideDoesntExistIsFalse()
        {
            TriangleTest result = new TriangleTest();

            Assert.AreEqual(true, result.Triangle(0, 2, 6));
        }
Example #4
0
        public void NegativeSideIsFalse()
        {
            TriangleTest result = new TriangleTest();

            Assert.AreEqual(true, result.Triangle(-2, 2, 2));
        }
Example #5
0
        public void TwoSidesIsNegativeIsFalse()
        {
            TriangleTest result = new TriangleTest();

            Assert.AreEqual(true, result.Triangle(-2, -2, 6));
        }
Example #6
0
        public void UsualSidesIsTrue()
        {
            TriangleTest result = new TriangleTest();

            Assert.AreEqual(true, result.Triangle(3, 4, 5));
        }
Example #7
0
        public void twoSidesAreEqualIsTrue()
        {
            TriangleTest result = new TriangleTest();

            Assert.AreEqual(true, result.Triangle(2, 6, 6));
        }
Example #8
0
    // Rigidbody rb;

    void OnDrawGizmos()
    {
        if (!mr)
        {
            return;
        }

        // Collider collider = mr.GetComponent<Collider>();
        // rb = GetComponent<Rigidbody>();

        Vector3 pos = transform.position;

        Vector3 colliderPos = mr.bounds.min;

        // var dir = colliderPos - pos;
        var dir = Vector3.left;

        Physics.queriesHitBackfaces = true;
        // Collider mc = GetComponent<Collider>();

        float tStamp = Time.realtimeSinceStartup;
        Ray   ray    = new Ray();

        // for (int i = 0; i < 1000000; i++)
        {
            ray.origin    = pos;
            ray.direction = dir;
            if (Physics.Raycast(ray, out hitInfo, 10000))
            {
                if (Vector3.Dot(dir, hitInfo.normal) >= 0)
                {
                    Gizmos.color = Color.green;
                }
                else
                {
                    Gizmos.color = Color.red;
                }

                Gizmos.DrawLine(hitInfo.point, hitInfo.point + hitInfo.normal);

                Gizmos.color = Color.white;
                Gizmos.DrawLine(pos, hitInfo.point);
            }
            else
            {
                Gizmos.color = Color.red;
                Gizmos.DrawLine(pos, pos + (dir.normalized * 1000));
            }
        }

        // float time = Time.realtimeSinceStartup - tStamp;
        // Debug.Log("Raycast Time " + time);

        // if (Physics.CheckBox(transform.position, transform.lossyScale * 0.5f)) Gizmos.color = Color.red; else Gizmos.color = Color.green;
        // Gizmos.DrawCube(transform.position, transform.lossyScale);
        // return;
        var mf   = GetComponent <MeshFilter>();
        var mesh = mf.sharedMesh;

        var sourceMf = mr.GetComponent <MeshFilter>();

        Mesh sourceMesh = sourceMf.sharedMesh;

        Vector3[] sourceVerts = sourceMesh.vertices;
        int[]     sourceTris  = sourceMesh.triangles;
        // return;
        // int triIndex = triangleIndex * 3;

        for (int triIndex = 0; triIndex < sourceTris.Length; triIndex += 3)
        {
            Vector3 vertPos1 = mr.transform.TransformPoint(sourceVerts[sourceTris[triIndex + 2]]);
            Vector3 vertPos2 = mr.transform.TransformPoint(sourceVerts[sourceTris[triIndex + 0]]);
            Vector3 vertPos3 = mr.transform.TransformPoint(sourceVerts[sourceTris[triIndex + 1]]);

            var tri = new TriangleTest();

            tri.a = vertPos1;
            tri.b = vertPos2;
            tri.c = vertPos3;

            tri.Calc();

            Vector3 origin = tri.a + (tri.dirAb / 2) + ((tri.c - tri.h1) / 2);

            if (Physics.CheckBox(origin, new Vector3(0.05f, tri.h, tri.ab) / 2, Quaternion.LookRotation(tri.dirAb, tri.dirAc)))
            {
                Gizmos.color = Color.red;

                Gizmos.DrawLine(tri.a, tri.b);
                Gizmos.DrawLine(tri.b, tri.c);
                Gizmos.DrawLine(tri.c, tri.a);
                Gizmos.DrawLine(tri.c, tri.h1);
            }
            else
            {
                Gizmos.color = Color.green;
            }

            //transform.position = tri.h1;

            //float distance = 0;

            //transform.localScale = new Vector3(1, tri.h, tri.hb);
            //transform.rotation = Quaternion.LookRotation(tri.dirAb, tri.dirAc);

            //Physics.SyncTransforms();

            //if (Physics.ComputePenetration(mc, transform.position, transform.rotation, collider, collider.transform.position, collider.transform.rotation, out dir, out distance))
            //{
            //    // Gizmos.DrawSphere(tri.h1, 0.01f);

            //    Gizmos.color = Color.blue;
            //    if (drawTriangle)
            //    {
            //        Gizmos.DrawLine(tri.a, tri.b);
            //        Gizmos.DrawLine(tri.b, tri.c);
            //        Gizmos.DrawLine(tri.c, tri.a);
            //        Gizmos.DrawLine(tri.c, tri.h1);
            //    }
            //}

            //transform.localScale = new Vector3(1, tri.h, tri.ah);
            //transform.rotation = Quaternion.LookRotation(-tri.dirAb, tri.dirAc);
            //Physics.SyncTransforms();

            //if (Physics.ComputePenetration(mc, transform.position, transform.rotation, collider, collider.transform.position, collider.transform.rotation, out dir, out distance))
            //{
            //    // Gizmos.DrawSphere(tri.h1, 0.01f);

            //    Gizmos.color = Color.blue;
            //    if (drawTriangle)
            //    {
            //        Gizmos.DrawLine(tri.a, tri.b);
            //        Gizmos.DrawLine(tri.b, tri.c);
            //        Gizmos.DrawLine(tri.c, tri.a);
            //        Gizmos.DrawLine(tri.c, tri.h1);
            //    }
            //}
        }

        Physics.queriesHitBackfaces = false;
    }
Example #9
0
        public void TwoSidesDoesntExistIsFalse()
        {
            TriangleTest result = new TriangleTest();

            Assert.AreEqual(true, esult.Triangle(0, 0, 6));
        }
        private void Collide()
        {
            // test collisions between objects and frustum
            this.secondarySpheres[0].Collision       = this.primaryFrustum.Contains(this.secondarySpheres[0].Sphere);
            this.secondaryOrientedBoxes[0].Collision = this.primaryFrustum.Contains(this.secondaryOrientedBoxes[0].Box);
            this.secondaryAABoxes[0].Collision       = this.primaryFrustum.Contains(this.secondaryAABoxes[0].Box);
            this.secondaryTriangles[0].Collision     = this.primaryFrustum.Contains(this.secondaryTriangles[0].PointA, this.secondaryTriangles[0].PointB, this.secondaryTriangles[0].PointC);

            // test collisions between objects and aligned box
            this.secondarySpheres[1].Collision       = this.primaryAABox.Contains(this.secondarySpheres[1].Sphere);
            this.secondaryOrientedBoxes[1].Collision = this.primaryAABox.Contains(this.secondaryOrientedBoxes[1].Box);
            this.secondaryAABoxes[1].Collision       = this.primaryAABox.Contains(this.secondaryAABoxes[1].Box);
            this.secondaryTriangles[1].Collision     = this.primaryAABox.Contains(this.secondaryTriangles[1].PointA, this.secondaryTriangles[1].PointB, this.secondaryTriangles[1].PointC);

            // test collisions between objects and oriented box
            this.secondarySpheres[2].Collision       = this.primaryOrientedBox.Contains(this.secondarySpheres[2].Sphere);
            this.secondaryOrientedBoxes[2].Collision = this.primaryOrientedBox.Contains(this.secondaryOrientedBoxes[2].Box);
            this.secondaryAABoxes[2].Collision       = this.primaryOrientedBox.Contains(this.secondaryAABoxes[2].Box);
            this.secondaryTriangles[2].Collision     = this.primaryOrientedBox.Contains(this.secondaryTriangles[2].PointA, this.secondaryTriangles[2].PointB, this.secondaryTriangles[2].PointC);

            // test collisions between objects and ray
            float fDistance = -1.0f;
            float d;

            if (this.secondarySpheres[3].Sphere.Intersects(
                    this.primaryRay.Origin,
                    this.primaryRay.Direction,
                    out d))
            {
                this.secondarySpheres[3].Collision = ContainmentType.Intersects;
                fDistance = d;
            }
            else
            {
                this.secondarySpheres[3].Collision = ContainmentType.Disjoint;
            }

            if (this.secondaryOrientedBoxes[3].Box.Intersects(
                    this.primaryRay.Origin,
                    this.primaryRay.Direction,
                    out d))
            {
                this.secondaryOrientedBoxes[3].Collision = ContainmentType.Intersects;
                fDistance = d;
            }
            else
            {
                this.secondaryOrientedBoxes[3].Collision = ContainmentType.Disjoint;
            }

            if (this.secondaryAABoxes[3].Box.Intersects(
                    this.primaryRay.Origin,
                    this.primaryRay.Direction,
                    out d))
            {
                this.secondaryAABoxes[3].Collision = ContainmentType.Intersects;
                fDistance = d;
            }
            else
            {
                this.secondaryAABoxes[3].Collision = ContainmentType.Disjoint;
            }

            if (TriangleTest.Intersects(
                    this.primaryRay.Origin,
                    this.primaryRay.Direction,
                    this.secondaryTriangles[3].PointA,
                    this.secondaryTriangles[3].PointB,
                    this.secondaryTriangles[3].PointC,
                    out d))
            {
                this.secondaryTriangles[3].Collision = ContainmentType.Intersects;
                fDistance = d;
            }
            else
            {
                this.secondaryTriangles[3].Collision = ContainmentType.Disjoint;
            }

            // If one of the ray intersection tests was successful, fDistance will be positive.
            // If so, compute the intersection location and store it in g_RayHitResultBox.
            if (fDistance > 0)
            {
                // The primary ray's direction is assumed to be normalized.
                XMVector hitLocation = XMVector.MultiplyAdd(
                    this.primaryRay.Direction,
                    XMVector.Replicate(fDistance),
                    this.primaryRay.Origin);

                BoundingBox box = this.rayHitResultBox.Box;
                box.Center = hitLocation;
                this.rayHitResultBox.Box = box;

                this.rayHitResultBox.Collision = ContainmentType.Intersects;
            }
            else
            {
                this.rayHitResultBox.Collision = ContainmentType.Disjoint;
            }
        }
Example #11
0
    private static void Main()
    //****************************************************************************80
    //
    //  Purpose:
    //
    //    MAIN is the main program for SUBSET_TEST.
    //
    //  Discussion:
    //
    //    SUBSET_TEST tests SUBSET.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    20 November 2019
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        Console.WriteLine("");
        Console.WriteLine("SUBSET_TEST");
        Console.WriteLine("  Test the SUBSET library.");

        AlternatingSignMatrixTest.asm_enum_test();
        AlternatingSignMatrixTest.asm_triangle_test();
        BellTest.bell_test();
        CatalanTest.catalan_test();
        CatalanTest.catalan_row_next_test();
        FractionTest.cfrac_to_rat_test();
        FractionTest.cfrac_to_rfrac_test();
        CombTest.comb_next_test();
        CombTest.comb_row_next_test();
        CombTest.comb_unrank_test();
        CompTest.comp_enum_test();
        CompTest.comp_next_test();
        CompTest.comp_next_grlex_test();
        CompTest.comp_random_test();
        CompTest.comp_random_grlex_test();
        CompTest.comp_rank_grlex_test();
        CompTest.comp_to_ksub_test();
        CompTest.comp_unrank_grlex_test();
        CompTest.compnz_next_test();
        CompTest.compnz_random_test();
        CompTest.compnz_to_ksub_test();
        CongruenceTest.congruence_test();
        DebruijnTest.debruijn_test();

        DecMatTest.decmat_det_test();
        DecMatTest.decmat_print_test();
        DerangeTest.derange_enum_test();
        DerangeTest.derange_enum2_test();
        DerangeTest.derange_enum3_test();
        DerangeTest.derange0_back_next_test();
        DerangeTest.derange0_check_test();
        DerangeTest.derange0_weed_next_test();
        DigraphTest.digraph_arc_euler_test();
        DigraphTest.digraph_arc_print_test();
        DiophantineTest.diophantine_test();
        DiophantineTest.diophantine_solution_minimize_test();
        DVecTest.dvec_add_test();
        DVecTest.dvec_complementx_test();
        DVecTest.dvec_mul_test();
        DVecTest.dvec_print_test();
        DVecTest.dvec_sub_test();
        DVecTest.dvec_to_i4_test();
        EquivTest.equiv_next_test();
        EquivTest.equiv_next2_test();
        EquivTest.equiv_print_test();
        EquivTest.equiv_print2_test();
        EquivTest.equiv_random_test();
        EulerTest.euler_row_test();
        FrobeniusTest.frobenius_number_order2_test();
        GrayTest.gray_next_test();
        GrayTest.gray_rank_test();
        GrayTest.gray_rank2_test();
        GrayTest.gray_unrank_test();
        GrayTest.gray_unrank2_test();
        i4Test.i4_bclr_test();
        i4Test.i4_bset_test();
        i4Test.i4_btest_test();
        i4Test.i4_choose_test();
        i4Test.i4_factor_test();
        i4Test.i4_fall_test();
        i4Test.i4_gcd_test();
        i4Test.i4_huge_test();
        i4Test.i4_log_10_test();
        i4Test.i4_modp_test();
        i4Test.i4_moebius_test();
        i4Test.i4_partition_conj_test();
        i4Test.i4_partition_count_test();
        i4Test.i4_partition_count2_test();
        i4Test.i4_partition_next_test();
        i4Test.i4_partition_next2_test();
        i4Test.i4_partition_print_test();
        i4Test.i4_partition_random_test();
        i4Test.i4_partitions_next_test();
        i4Test.i4_rise_test();
        i4Test.i4_sqrt_test();
        i4Test.i4_sqrt_cf_test();
        i4Test.i4_to_dvec_test();
        i4Test.i4_to_i4poly_test();
        i4Test.i4_to_van_der_corput_test();
        i4Test.i4mat_01_rowcolsum_test();
        i4Test.i4mat_u1_inverse_test();
        i4Test.i4mat_perm0_test();
        i4Test.i4mat_2perm0_test();
        i4Test.i4poly_test();
        i4Test.i4poly_add_test();
        i4Test.i4poly_cyclo_test();
        i4Test.i4poly_degree_test();
        i4Test.i4poly_dif_test();
        i4Test.i4poly_div_test();
        i4Test.i4poly_mul_test();
        i4Test.i4poly_print_test();
        i4Test.i4poly_to_i4_test();
        i4Test.i4vec_backtrack_test();
        i4Test.i4vec_descends_test();
        i4Test.i4vec_frac_test();
        i4Test.i4vec_index_test();
        i4Test.i4vec_maxloc_last_test();
        i4Test.i4vec_pairwise_prime_test();
        i4Test.i4vec_reverse_test();
        i4Test.i4vec_sort_bubble_a_test();
        i4Test.i4vec_sort_heap_index_d_test();
        i4Test.i4vec_transpose_print_test();
        i4Test.i4vec_uniform_ab_test();
        IndexTest.index_box_next_2d_test();
        IndexTest.index_box_next_3d_test();
        IndexTest.index_box2_next_2d_test();
        IndexTest.index_box2_next_3d_test();
        IndexTest.index_next0_test();
        IndexTest.index_next1_test();
        IndexTest.index_next2_test();
        IndexTest.index_rank0_test();
        IndexTest.index_rank1_test();
        IndexTest.index_rank2_test();
        IndexTest.index_unrank0_test();
        IndexTest.index_unrank1_test();
        IndexTest.index_unrank2_test();
        InverseTest.inverse_mod_n_test();
        PermTest.inversion_to_perm0_test();
        InvoluteTest.involute_enum_test();
        FractionTest.jfrac_to_rfrac_test();
        JosephusTest.josephus_test();
        KsubTest.ksub_next_test();
        KsubTest.ksub_next2_test();
        KsubTest.ksub_next3_test();
        KsubTest.ksub_next4_test();
        KsubTest.ksub_random_test();
        KsubTest.ksub_random2_test();
        KsubTest.ksub_random3_test();
        KsubTest.ksub_random4_test();
        KsubTest.ksub_random5_test();
        KsubTest.ksub_rank_test();
        KsubTest.ksub_to_comp_test();
        KsubTest.ksub_to_compnz_test();
        KsubTest.ksub_unrank_test();
        l4Test.l4vec_next_test();
        MatrixTest.matrix_product_opt_test();
        MoebiusMatrixTest.moebius_matrix_test();
        MonomialTest.monomial_count_test();
        MonomialTest.monomial_counts_test();
        MorseThueTest.morse_thue_test();
        MultinomialTest.multinomial_coef1_test();
        MultinomialTest.multinomial_coef2_test();
        PermTest.multiperm_enum_test();
        PermTest.multiperm_next_test();
        UnsignTest.nim_sum_test();
        PadovanTest.padovan_test();
        PellTest.pell_basic_test();
        PellTest.pell_next_test();
        PentEnumTest.pent_enum_test();
        PermTest.perm_ascend_test();
        PermTest.perm_fixed_enum_test();
        PermTest.perm0_break_count_test();
        PermTest.perm0_check_test();
        PermTest.perm0_cycle_test();
        PermTest.perm0_distance_test();
        PermTest.perm0_free_test();
        PermTest.perm0_inverse_test();
        PermTest.perm0_inverse2_test();
        PermTest.perm0_inverse3_new_test();
        PermTest.perm0_lex_next_test();
        PermTest.perm0_mul_test();
        PermTest.perm0_next_test();
        PermTest.perm0_next2_test();
        PermTest.perm0_next3_test();
        PermTest.perm0_print_test();
        PermTest.perm0_random_test();
        PermTest.perm0_random2_test();
        PermTest.perm0_rank_test();
        PermTest.perm0_sign_test();
        PermTest.perm0_to_equiv_test();
        PermTest.perm0_to_inversion_test();
        PermTest.perm0_to_ytb_test();
        PermTest.perm0_unrank_test();
        PermTest.perm1_canon_to_cycle_test();
        PermTest.perm1_check_test();
        PermTest.perm1_cycle_to_canon_test();
        PermTest.perm1_cycle_to_index_test();
        PermTest.perm1_index_to_cycle_test();
        PermTest.perm1_print_test();
        PerrinTest.perrin_test();
        PartialOrderingTest.pord_check_test();
        PowerTest.power_mod_test();
        PowerTest.power_series1_test();
        PowerTest.power_series2_test();
        PowerTest.power_series3_test();
        PowerTest.power_series4_test();
        PrimeTest.prime_test();
        PythagorusTest.pythag_triple_next_test();
        r8Test.r8_agm_test();
        r8Test.r8_choose_test();
        r8Test.r8_epsilon_test();
        r8Test.r8_fall_test();
        r8Test.r8_rise_test();
        r8Test.r8_to_cfrac_test();
        r8Test.r8_to_dec_test();
        r8Test.r8_to_rat_test();
        r8Test.r8mat_det_test();
        r8Test.r8mat_perm0_test();
        r8Test.r8mat_2perm0_test();
        r8Test.r8mat_permanent_test();
        r8Test.r8poly_test();
        r8Test.r8poly_f2p_test();
        r8Test.r8poly_fval_test();
        r8Test.r8poly_n2p_test();
        r8Test.r8poly_nval_test();
        r8Test.r8poly_nx_test();
        r8Test.r8poly_p2f_test();
        r8Test.r8poly_p2n_test();
        r8Test.r8poly_p2t_test();
        r8Test.r8poly_print_test();
        r8Test.r8poly_pval_test();
        r8Test.r8poly_t2p_test();
        r8Test.r8vec_backtrack_test();
        r8Test.r8vec_frac_test();
        r8Test.r8vec_mirror_next_test();
        RationalTest.rat_add_test();
        RationalTest.rat_div_test();
        RationalTest.rat_farey_test();
        RationalTest.rat_farey2_test();
        RationalTest.rat_mul_test();
        RationalTest.rat_normalize_test();
        RationalTest.rat_sum_formula_test();
        RationalTest.rat_to_cfrac_test();
        RationalTest.rat_to_dec_test();
        RationalTest.rat_to_r8_test();
        RationalTest.rat_to_s_test();
        RationalTest.rat_width_test();
        RationalTest.ratmat_det_test();
        RationalTest.ratmat_print_test();
        RestrictedGrowthTest.regro_next_test();
        FractionTest.rfrac_to_cfrac_test();
        FractionTest.rfrac_to_jfrac_test();
        SchroederTest.schroeder_test();
        SortHeapExternalTest.sort_heap_external_test();
        SubsetTest.subset_by_size_next_test();
        SubsetTest.subset_lex_next_test();
        SubsetTest.subset_gray_next_test();
        SubsetTest.subset_random_test();
        SubsetTest.subset_gray_rank_test();
        SubsetTest.subset_gray_unrank_test();
        SubcompTest.subcomp_next_test();
        SubcompTest.subcompnz_next_test();
        SubcompTest.subcompnz2_next_test();
        TriangleTest.subtriangle_next_test();
        Thuetest.thue_binary_next_test();
        Thuetest.thue_ternary_next_test();
        TriangTest.triang_test();
        TupleTest.tuple_next_test();
        TupleTest.tuple_next_fast_test();
        TupleTest.tuple_next_ge_test();
        TupleTest.tuple_next2_test();
        UnsignTest.ubvec_add_test();
        UnsignTest.ubvec_print_test();
        UnsignTest.ubvec_to_ui4_test();
        UnsignTest.ubvec_xor_test();
        UnsignTest.ui4_to_ubvec_test();
        VectorTest.vec_colex_next_test();
        VectorTest.vec_colex_next2_test();
        VectorTest.vec_colex_next3_test();
        VectorTest.vec_gray_next_test();
        VectorTest.vec_gray_rank_test();
        VectorTest.vec_gray_unrank_test();
        VectorTest.vec_lex_next_test();
        VectorTest.vec_random_test();
        VectorTest.vector_constrained_next_test();
        VectorTest.vector_constrained_next2_test();
        VectorTest.vector_constrained_next3_test();
        VectorTest.vector_constrained_next4_test();
        VectorTest.vector_constrained_next5_test();
        VectorTest.vector_constrained_next6_test();
        VectorTest.vector_constrained_next7_test();
        VectorTest.vector_next_test();
        YoungTableauTest.ytb_enum_test();
        YoungTableauTest.ytb_next_test();
        YoungTableauTest.ytb_random_test();
        Console.WriteLine("");
        Console.WriteLine("SUBSET_TEST");
        Console.WriteLine("  Normal end of execution.");
        Console.WriteLine("");
    }
        private void radBallType_CheckedChanged(object sender, EventArgs e)
        {
            grpTriangleZ.Visible = false;
            grpTriangleZ2.Visible = false;
            _triangle1 = null;
            _triangle2 = null;
            _polygon1 = null;
            _polygon2 = null;

            if (radBallBall.Checked || radSolidBallSolidBall.Checked)
            {
                #region Balls

                Ball newBall1, newBall2;

                if (radBallBall.Checked)
                {
                    // Switch them out with a standard ball
                    newBall1 = new Ball(_ball1.Position.Clone(), new DoubleVector(0, 1, 0, 1, 0, 0), _ball1.Radius, _ball1.Mass, _ball1.Elasticity, _ball1.KineticFriction, _ball1.StaticFriction, _boundryLower, _boundryUpper);
                    newBall1.Velocity.StoreNewValues(_ball1.Velocity.Clone());

                    newBall2 = new Ball(_ball2.Position.Clone(), new DoubleVector(0, 1, 0, 1, 0, 0), _ball2.Radius, _ball2.Mass, _ball2.Elasticity, _ball2.KineticFriction, _ball2.StaticFriction, _boundryLower, _boundryUpper);
                    newBall2.Velocity.StoreNewValues(_ball2.Velocity.Clone());
                }
                else if (radSolidBallSolidBall.Checked)
                {
                    // Switch them out with solidballs
                    newBall1 = new SolidBall(_ball1.Position.Clone(), new DoubleVector(0, 1, 0, 1, 0, 0), _ball1.Radius, _ball1.Mass, _ball1.Elasticity, _ball1.KineticFriction, _ball1.StaticFriction, _boundryLower, _boundryUpper);
                    newBall1.Velocity.StoreNewValues(_ball1.Velocity.Clone());
                    ((SolidBall)newBall1).AngularVelocity.StoreNewValues(new MyVector(0, 0, 200));

                    newBall2 = new SolidBall(_ball2.Position.Clone(), new DoubleVector(0, 1, 0, 1, 0, 0), _ball2.Radius, _ball2.Mass, _ball2.Elasticity, _ball2.KineticFriction, _ball2.StaticFriction, _boundryLower, _boundryUpper);
                    newBall2.Velocity.StoreNewValues(_ball2.Velocity.Clone());
                    ((SolidBall)newBall2).AngularVelocity.StoreNewValues(new MyVector(0, 0, 200));
                }
                else
                {
                    MessageBox.Show("Unknown radio button", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                _ball1 = newBall1;
                _ball2 = newBall2;

                #endregion
            }
            else if (radSphereSphere.Checked)
            {
                #region Spheres

                // leave the balls alone?

                #endregion
            }
            else if (radLineTriangle.Checked || radSphereTriangle.Checked || radTriangleTriangle.Checked)
            {
                #region Triangles

                if (radLineTriangle.Checked)
                {
                    #region Line Triangle

                    // I will leave ball1 alone.  I will use that one's velocity as the line

                    grpTriangleZ.Visible = true;

                    // Make the the triangle
                    if (chkTrianglePerpendicular.Checked)
                    {
                        _triangle1 = new TriangleTest(_ball2.Position.Clone(), new DoubleVector(1, 0, 0, 0, 1, 0), new Triangle(0, 0, -100, 0, 100, 0, 0, -100, 100));

                        radPoint1Neg.Enabled = radPoint1Pos.Enabled = radPoint1Zero.Enabled = false;
                        radPoint2Neg.Enabled = radPoint2Pos.Enabled = radPoint2Zero.Enabled = false;
                        radPoint3Neg.Enabled = radPoint3Pos.Enabled = radPoint3Zero.Enabled = false;
                    }
                    else
                    {
                        _triangle1 = new TriangleTest(_ball2.Position.Clone(), new DoubleVector(1, 0, 0, 0, 1, 0), new Triangle(-150, -150, 0, 150, -150, 0, 0, 150, 0));

                        radPoint1Neg.Enabled = radPoint1Pos.Enabled = radPoint1Zero.Enabled = true;
                        radPoint2Neg.Enabled = radPoint2Pos.Enabled = radPoint2Zero.Enabled = true;
                        radPoint3Neg.Enabled = radPoint3Pos.Enabled = radPoint3Zero.Enabled = true;

                        radPoint1_CheckedChanged(this, new EventArgs());
                        radPoint2_CheckedChanged(this, new EventArgs());
                        radPoint3_CheckedChanged(this, new EventArgs());
                    }

                    #endregion
                }
                else if (radSphereTriangle.Checked)
                {
                    #region Sphere Triangle

                    // I will leave ball1 alone.  I won't use its velocity, just radius

                    grpTriangleZ.Visible = true;

                    // Make the the triangle
                    if (chkTrianglePerpendicular.Checked)
                    {
                        _triangle1 = new TriangleTest(_ball2.Position.Clone(), new DoubleVector(1, 0, 0, 0, 1, 0), new Triangle(0, 0, -100, 0, 100, 0, 0, -100, 100));

                        radPoint1Neg.Enabled = radPoint1Pos.Enabled = radPoint1Zero.Enabled = false;
                        radPoint2Neg.Enabled = radPoint2Pos.Enabled = radPoint2Zero.Enabled = false;
                        radPoint3Neg.Enabled = radPoint3Pos.Enabled = radPoint3Zero.Enabled = false;
                    }
                    else
                    {
                        _triangle1 = new TriangleTest(_ball2.Position.Clone(), new DoubleVector(1, 0, 0, 0, 1, 0), new Triangle(-150, -150, 0, 150, -150, 0, 0, 150, 0));

                        radPoint1Neg.Enabled = radPoint1Pos.Enabled = radPoint1Zero.Enabled = true;
                        radPoint2Neg.Enabled = radPoint2Pos.Enabled = radPoint2Zero.Enabled = true;
                        radPoint3Neg.Enabled = radPoint3Pos.Enabled = radPoint3Zero.Enabled = true;

                        radPoint1_CheckedChanged(this, new EventArgs());
                        radPoint2_CheckedChanged(this, new EventArgs());
                        radPoint3_CheckedChanged(this, new EventArgs());
                    }

                    #endregion
                }
                else if (radTriangleTriangle.Checked)
                {
                    #region Triangle Triangle

                    grpTriangleZ.Visible = true;
                    grpTriangleZ2.Visible = true;

                    #region Triangle1 (right side)

                    // Make the the triangle
                    if (chkTrianglePerpendicular.Checked)
                    {
                        _triangle1 = new TriangleTest(_ball2.Position.Clone(), new DoubleVector(1, 0, 0, 0, 1, 0), new Triangle(0, 0, -100, 0, 100, 0, 0, -100, 100));

                        radPoint1Neg.Enabled = radPoint1Pos.Enabled = radPoint1Zero.Enabled = false;
                        radPoint2Neg.Enabled = radPoint2Pos.Enabled = radPoint2Zero.Enabled = false;
                        radPoint3Neg.Enabled = radPoint3Pos.Enabled = radPoint3Zero.Enabled = false;
                    }
                    else
                    {
                        _triangle1 = new TriangleTest(_ball2.Position.Clone(), new DoubleVector(1, 0, 0, 0, 1, 0), new Triangle(-150, -150, 0, 150, -150, 0, 0, 150, 0));

                        radPoint1Neg.Enabled = radPoint1Pos.Enabled = radPoint1Zero.Enabled = true;
                        radPoint2Neg.Enabled = radPoint2Pos.Enabled = radPoint2Zero.Enabled = true;
                        radPoint3Neg.Enabled = radPoint3Pos.Enabled = radPoint3Zero.Enabled = true;

                        radPoint1_CheckedChanged(this, new EventArgs());
                        radPoint2_CheckedChanged(this, new EventArgs());
                        radPoint3_CheckedChanged(this, new EventArgs());
                    }

                    #endregion
                    #region Triangle2 (left side)

                    // Make the the triangle
                    if (chkTrianglePerpendicular2.Checked)
                    {
                        _triangle2 = new TriangleTest(_ball1.Position.Clone(), new DoubleVector(1, 0, 0, 0, 1, 0), new Triangle(0, 0, -100, 0, 100, 0, 0, -100, 100));

                        radPoint1Neg2.Enabled = radPoint1Pos2.Enabled = radPoint1Zero2.Enabled = false;
                        radPoint2Neg2.Enabled = radPoint2Pos2.Enabled = radPoint2Zero2.Enabled = false;
                        radPoint3Neg2.Enabled = radPoint3Pos2.Enabled = radPoint3Zero2.Enabled = false;
                    }
                    else
                    {
                        _triangle2 = new TriangleTest(_ball1.Position.Clone(), new DoubleVector(1, 0, 0, 0, 1, 0), new Triangle(-150, -150, 0, 150, -150, 0, 0, 150, 0));

                        radPoint1Neg2.Enabled = radPoint1Pos2.Enabled = radPoint1Zero2.Enabled = true;
                        radPoint2Neg2.Enabled = radPoint2Pos2.Enabled = radPoint2Zero2.Enabled = true;
                        radPoint3Neg2.Enabled = radPoint3Pos2.Enabled = radPoint3Zero2.Enabled = true;

                        radPoint1Changed2_CheckedChanged(this, new EventArgs());
                        radPoint2Changed2_CheckedChanged(this, new EventArgs());
                        radPoint3Changed2_CheckedChanged(this, new EventArgs());
                    }

                    #endregion

                    #endregion
                }
                else
                {
                    MessageBox.Show("Unknown radio button", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                #endregion
            }
            else
            {
                #region Polygons

                if (radSpherePolygon.Checked)
                {
                    #region Sphere Polygon

                    // I will leave ball1 alone.  I won't use its velocity, just radius

                    // Make the the polygon
                    //_polygon1 = new PolygonTest(_ball2.Position.Clone(), new DoubleVector(1, 0, 0, 0, 1, 0), Polygon.CreateTetrahedron(_ball2.Radius * 2, true), _ball2.Radius * 2);
                    _polygon1 = new PolygonTest(_ball2.Position.Clone(), new DoubleVector(1, 0, 0, 0, 1, 0), MyPolygon.CreateCube(_ball2.Radius * 5, true), _ball2.Radius * 4);

                    #endregion
                }
                else if (radPolygonPolygon.Checked)
                {
                    #region Polygon Polygon

                    // Polygon1 is on the right (so it uses ball2 as its source)
                    _polygon1 = new PolygonTest(_ball2.Position.Clone(), new DoubleVector(1, 0, 0, 0, 1, 0), MyPolygon.CreateTetrahedron(_ball2.Radius * 2, true), _ball2.Radius * 2);
                    _polygon2 = new PolygonTest(_ball1.Position.Clone(), new DoubleVector(1, 0, 0, 0, 1, 0), MyPolygon.CreateCube(_ball1.Radius * 2, true), _ball2.Radius * 2);

                    #endregion
                }
                else
                {
                    MessageBox.Show("Unknown radio button", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                #endregion
            }
        }
Example #13
0
    private static void Main()
    //****************************************************************************80
    //
    //  Purpose:
    //
    //    MAIN is the main program for GEOMETRY_PRB.
    //
    //  Discussion:
    //
    //    GEOMETRY_PRB tests the GEOMETRY library.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //   20 January 2018
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        Console.WriteLine("");
        Console.WriteLine("GEOMETRY_PRB");
        Console.WriteLine("  Test the GEOMETRY library.");

        AngleTest.angle_box_2d_test();
        AngleTest.angle_contains_ray_2d_test();
        AngleTest.angle_deg_2d_test();
        AngleTest.angle_half_2d_test();
        AngleTest.angle_rad_2d_test();
        AngleTest.angle_rad_3d_test();
        AngleTest.angle_rad_nd_test();
        AngleTest.angle_turn_2d_test();

        AnnulusTest.annulus_sector_centroid_2d_test();

        BallTest.ball01_sample_2d_test();
        BallTest.ball01_sample_3d_test();
        BallTest.ball01_sample_nd_test();
        BallTest.ball01_volume_test();

        BasisTest.basis_map_3d_test();

        BoxTest.box_contains_point_2d_test();

        BoxTest.box_segment_clip_2d_test();
        BoxTest.box_ray_int_2d_test();
        BoxTest.box01_contains_point_2d_test();

        CircleTest.circle_dia2imp_2d_test();

        CircleTest.circle_exp_contains_point_2d_test();
        CircleTest.circle_exp2imp_2d_test();

        CircleTest.circle_imp_point_dist_2d_test();
        CircleTest.circle_imp_points_arc_2d_test();

        CircleTest.circle_llr2imp_2d_test();

        CircleTest.circle_lune_angle_by_height_2d_test();
        CircleTest.circle_lune_area_by_angle_2d_test();
        CircleTest.circle_lune_area_by_height_2d_test();
        CircleTest.circle_lune_centroid_2d_test();
        CircleTest.circle_lune_height_by_angle_2d_test();

        CircleTest.circle_pppr2imp_3d_test();

        CircleTest.circle_ppr2imp_2d_test();

        CircleTest.circle_sector_area_2d_test();
        CircleTest.circle_sector_centroid_2d_test();

        CircleTest.circle_triangle_area_2d_test();

        CircleTest.test0155();
        CircleTest.test0156();
        CircleTest.test016();
        CircleTest.test0165();

        CircleTest.circles_intersect_area_2d_test();
        CircleTest.circles_intersect_points_2d_test();

        CubeTest.test020();

        CubeTest.cube01_volume_test();

        CylinderTest.cylinder_point_dist_3d_test();
        CylinderTest.cylinder_point_dist_signed_3d_test();

        CylinderTest.test0202();
        CylinderTest.test0203();
        CylinderTest.test02035();
        CylinderTest.test0204();
        DegRadTest.test0205();
        DirectionTest.test021();
        DirectionTest.test022();

        DirectionTest.direction_uniform_nd_test();

        DiskPointTest.disk_point_dist_3d_test();

        r8Test.test0234();
        dmsradTest.test0235();
        DodecahedronTest.test0236();

        DualTest.dual_size_3d_test();
        DualTest.dual_shape_3d_test();


        EllipseTest.test025();

        EllipseTest.ellipse_area1_test();
        EllipseTest.ellipse_area2_test();
        EllipseTest.ellipse_area3_test();
        EllipseTest.ellipse_point_near_2d_test();

        EllipseTest.test026();

        EllipseTest.ellipse_points_arc_2d_test();

        HalfTest.halfplane_contains_point_2d_test();

        HalfTest.test029();
        HalfTest.test030();
        HaversineTest.test031();
        HexagonTest.test0315();
        HexagonTest.test032();
        HexagonTest.test0321();
        i4Test.test0322();
        i4Test.test0323();
        IcosahedronTest.test0325();
        LinesTest.test0327();

        LinesTest.line_exp_perp_2d_test();
        LinesTest.line_exp_point_dist_2d();

        LinesTest.test0336();
        LinesTest.test0337();
        LinesTest.test034();
        LinesTest.test0345();
        LinesTest.test0346();

        LinesTest.line_imp_point_dist_2d_test();

        LinesTest.test0351();
        LinesTest.test0352();
        LinesTest.test038();
        LinesTest.test0385();
        LinesTest.test03855();
        LinesTest.test0386();

        LinesTest.lines_exp_int_2d_test();

        LinesTest.test040();
        LinesTest.test041();
        LinesTest.test0415();
        LinesTest.test0416();
        SegmentTest.test0418();
        SegmentTest.test042();
        SegmentTest.test043();
        SegmentTest.test044();
        SegmentTest.test045();
        LocalMinimumTest.test046();
        LocalMinimumTest.test047();
        OctahedronTest.test0475();
        ParallelogramTest.test0477();
        ParallelogramTest.test0478();

        ParallelogramTest.parallelogram_contains_point_2d_test();
        ParallelogramTest.parallelogram_contains_point_2d_test2();
        ParallelogramTest.parallelogram_contains_point_3d_test();

        ParabolaTest.test0493();
        ParallelepipedTest.test0495();

        PlaneTest.plane_exp_normal_3d_test();

        PlaneTest.test051();
        PlaneTest.test052();
        PlaneTest.test053();
        PlaneTest.test054();

        PlaneTest.plane_imp2normal_3d_test();
        PlaneTest.plane_imp_line_par_int_3d_test();

        PlaneTest.test057();
        PlaneTest.test058();
        PlaneTest.test059();
        PlaneTest.test060();
        PlaneTest.test061();
        PlaneTest.test0615();
        PlaneTest.test0616();
        PlaneTest.test0617();
        PlaneTest.test062();
        PlaneTest.test063();
        PlaneTest.test064();

        PointsTest.points_centroid_2d_test();
        PointsTest.points_colin_2d_test();

        SphereTest.test068();
        PolarTest.test0685();
        PolygonTest.test0755();

        PolygonTest.polygon_angles_2d_test();

        PolygonTest.test076();
        PolygonTest.test0765();
        PolygonTest.test078();
        PolygonTest.test0782();
        PolygonTest.test0784();

        PolygonTest.polygon_centroid_3d_test();
        PolygonTest.polygon_contains_point_2d_test();
        PolygonTest.polygon_contains_point_2d_2_test();
        PolygonTest.polygon_contains_point_2d_3_test();

        PolygonTest.test080();
        PolygonTest.test0803();
        PolygonTest.test0805();

        PolygonTest.polygon_solid_angle_3d_test();

        PolyhedronTest.polyhedron_area_3d_test();
        PolyhedronTest.polyhedron_centroid_3d_test();

        PolyhedronTest.test0825();
        PolyhedronTest.test083();
        PolylineTest.test084();

        PolylineTest.polyline_points_nd_test();

        PolyloopTest.test0845();
        PolyloopTest.test0846();

        PlaneTest.plane_exp_pro3_test();

        ProvecTest.test170();
        QuadrilateralTest.test171();
        QuadrilateralTest.test1712();
        QuadrilateralTest.test1715();

        r8Test.r8_acos_test();
        r8Test.r8_asin_test();
        r8Test.r8_atan_test();

        r8Test.test0243();
        r8Test.test0245();
        RadecTest.test173();
        RadecTest.test174();
        r8Test.test1745();
        r8Test.test1746();
        DGETest.test1787();
        XYTest.test1893();
        SegmentTest.test036();
        SegmentTest.test0365();

        SegmentTest.segment_point_dist_3d_test();
        SegmentTest.segment_point_near_2d_test();
        SegmentTest.segment_point_near_3d_test();
        SegmentTest.segment_point_near_3d_test2();

        SimplexTest.test1788();
        SimplexTest.test1789();
        IcosahedronTest.test179();
        SortHeapTest.test180();
        SimplexTest.test1805();
        SphereTest.test0125();
        SphereTest.test0126();
        SphereTest.test0127();

        SphereTest.sphere_dia2imp_3d_test();

        SphereTest.test182();
        SphereTest.test183();
        SphereTest.test1835();
        SphereTest.test1836();
        SphereTest.test187();
        SphereTest.test188();
        SphereTest.test189();
        SphereTest.test1892();
        SphereTest.test1895();
        SphereTest.test190();
        SphereTest.test191();
        SphereTest.test192();
        SphereTest.test193();

        SphereTest.sphere_unit_sample_nd_2_test();

        SphereTest.test195();
        SphereTest.test1955();
        ShapeTest.test196();
        ShapeTest.test197();
        ShapeTest.test198();
        ShapeTest.test199();
        SphereTest.test200();
        SegmentTest.test201();
        EllipseTest.test202();
        TetrahedronTest.test203();
        TetrahedronTest.test2031();
        TetrahedronTest.test2032();
        TetrahedronTest.test20321();
        TetrahedronTest.test20322();

        TetrahedronTest.tetrahedron_lattice_layer_point_next_test();

        TetrahedronTest.test203225();
        TetrahedronTest.test20323();
        TetrahedronTest.test203232();
        TetrahedronTest.test203233();
        TetrahedronTest.test203234();
        TetrahedronTest.test203235();
        TetrahedronTest.test20324();
        TetrahedronTest.test20325();

        TetrahedronTest.tetrahedron_solid_angles_3d_test();

        TetrahedronTest.test2033();
        TransMatTest.test204();
        TransMatTest.test205();

        TriangleTest.triangle_angles_2d_test();

        TriangleTest.test20605();
        TriangleTest.test2061();
        TriangleTest.test2062();
        TriangleTest.test209();
        TriangleTest.test20655();
        TriangleTest.test2066();
        TriangleTest.test2094();
        TriangleTest.test2101();
        TriangleTest.test21011();
        TriangleTest.test2067();
        TriangleTest.test21015();

        TriangleTest.triangle_contains_line_exp_3d_test();
        TriangleTest.triangle_contains_line_par_3d_test();

        TriangleTest.test207();
        TriangleTest.test2075();
        TriangleTest.test208();
        TriangleTest.test2102();
        TriangleTest.test2070();
        TriangleTest.test20701();
        TriangleTest.test2104();
        TriangleTest.test2105();
        TriangleTest.test211();
        TriangleTest.test2103();
        TriangleTest.test2071();
        TriangleTest.test20715();

        TriangleTest.triangle_point_dist_3d_test();
        TriangleTest.triangle_point_near_2d_test();
        TriangleTest.triangle_quality_2d_test();

        TriangleTest.test212();
        TriangleTest.test213();

        TubeTest.tube_2d_test();

        VectorTest.vector_directions_nd_test();
        VectorTest.vector_rotate_2d_test();
        VectorTest.vector_rotate_3d_test();
        VectorTest.vector_rotate_base_2d_test();
        VectorTest.vector_separation_nd_test();

        VoxelTest.voxels_dist_l1_nd_test();
        VoxelTest.voxels_line_3d_test();
        VoxelTest.voxels_region_3d_test();
        VoxelTest.voxels_step_3d_test();

        WedgeTest.wedge01_volume_test();

        Console.WriteLine("");
        Console.WriteLine("GEOMETRY_PRB");
        Console.WriteLine("  Normal end of execution.");
        Console.WriteLine("");
    }
Example #14
0
 private static void Main()
 {
     EllipseTest.ellipse();
     RectangleTest.rectangle();
     TriangleTest.triangle();
 }