Giter VIP home page Giter VIP logo

geometri.csharp's People

Contributors

foggyfinder avatar risearcher avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

geometri.csharp's Issues

IntersectionWith error when lines are parallel

Hi,

If you try to get intersection of 2 parallel lines, it will crash with a "NullReferenceException".
In method "IntersectionWith" of Line3d (line 258) :

Point3d p = l.PerpendicularTo(this);

"p" is null and it's not checked in the following line.
[compiled on net7.0 (C# 11.0)]

Best regards,
Jonathan

How to get angles of global axis rotation

Hi Sergey,
Please help me with the following issue.
We have a global coordinate system X,Y,Z
There are 3 origin vectors (perpendicular to each orher (Cartesian) with unit length): V1, V2, V3.
There are 3 target vectors (perpendicular to each orher (Cartesian) with unit length): U1, U2, U3.
I have to get the 3 angles which are rotation angles around the global axes ta get from V1, V2, V3 to U1, U2, U3.
I am happy to see that your library contains quaternions.
Although I am not familiar with quaternions, but probably it would be the easyest if I created 2 orientation quaternions q1 = V1,V2,V3; q2 = U1,U2,U3
There is an equation: q2 = q1 * S
q2 * inverse(q1) = S
S is the rotation transformation which transforms V1,V2,V3 to U1,U2,U3.
How can I get from S the rotation angles on X, Y, Z?
Coordinate_rotation
Thanky ou for your help!
Tamás

Distance from point to plane?

Not an issue. I just discovered this library today. Looks like it has a lot of really good features that Accord.net does not have (doubles instead of floats, intersections between planes and other entities, etc.).

My question...Is there a way to calculate the distance between a point and a plane? I need to tell if a point in 3D space is between two planes.

small tolerance in segment3D.Intersect

In the file Segment3D.cs there is a 'double small = 1E-09;'. This might look small enough but for the segments defined in the following vb code

Dim ds As Double

        Dim p1 As New GeometRi.Point3d(0.209369, 0.857752, 0)
        Dim p2 As New GeometRi.Point3d(0.306139, 0.828827, 0)
        Dim p3 As New GeometRi.Point3d(0.230761, 0.851433, 0)
        Dim p4 As New GeometRi.Point3d(0.327265, 0.821633, 0)
        Dim l1 As New GeometRi.Segment3d(p1, p2)
        Dim l2 As New GeometRi.Segment3d(p3, p4)
        ds = l2.DistanceTo(l1)

it makes the 'DistanceTo' to report the distance as 0.007953 and not as 0.0 as they intersect. They seem parallel but they are not so my suggestion would be to decrease the tolerance even more. When I run your code the DD for these two segments is 8.5318104768448066E-09.

clipboard02
clipboard01

Operator == with null

Hi,
Should not we check if the object is not null in the operators == before calling the Equals method?
The following code crashes:
Point3d point = null; if(point == null) { }

Best regards,
Jonathan

Distance between parallel segments no calculated properly

Hi,

I am calculating the distance between two parallel segments and the results are not correct. in some cases. THe segments would be something like this:

image

The current algorithm I believe is calculating the distance between a pair of points of both segments, and the only way I got the correct distance is by doing.

segment1.DistanceTo(segment2.ToLine);

I was able to use this modified alternative because I know the span of both segments, but I believe the DistanceTo method can be modified to correctly catch this case.

Vector3d.AngleTo method misleading

var angle = vector.Coord.Xaxis.AngleTo(vector);

Not sure if I'm explaining this right.

The above method returns the angle between the x axis and the vector, but the method name implies that the result should be the directional angle from the x-axis to the vector (hence "AngleTo"). The difference is that the method currently returns the absolute value of the angle without direction, meaning vectors (1,-1,0) and (1,1,0) both return pi/4 and there's no indication of rotation from v1 to v2. I believe standard convention is that a positive angle implies CCW rotation and a negative angle implies CW rotation.

Segment to triangle distance with points

I follow the development of this library. I am a satisfied user of this! :)
Would it be difficult to get the distance and the closest points between a segment and a triangle?
And then later the distance and closest points between two triangles?
Thank you!

Coordinate rotation/translation does not have effect when creating objects

Hello,

I was testing how the coordinate system works, and noticed, that after rotating a coordinate system, it does work on the .Xaxis, .Yaxis and .Zaxis of this coordinate system, but after that, it seem that the rotation is somehow "forgotten" when i create for instance a Point3d object.

example test code below :

//  Coord Test
         Point3d Origin1 = new Point3d(1, 1, 0);
         Vector3d x1 = new Vector3d(0,1, 0);
         Vector3d y1 = new Vector3d(-1, 0, 0);

         Coord3d coord1 = new Coord3d(Origin1, x1, y1, "Coord1");
         coord1.Rotate(coord1.Zaxis, Math.PI/2);
         Point3d p_test = new Point3d(1, 0, 0, coord1); // ISSUE : does not apply the rotated coordinate system (expect (0,-1,0) instead of (0,1,0) in the global coord system)
         Point3d p_test2 = p_test.ConvertToGlobal();

Thank you for your feedback !

PS (a bit out of topic): Lets say we previously created a Point3d according to a custom coordinate system. How does it behave after rotating/translating this custom coordinate system ?
I think that it does not change any coordinate value X,Y,Z, of the Point3d, but this point still refers to the same coordinate system that has been changed ... seems pretty dangerous to me :).

Intersection of a segment with a circle returns an unexpected result

Hi. I encountered a possible issue with intersecting a line segment with a circle. The intersection result seems to be in a different coordinate system (?).

var circle = new Circle3d(new(400, 300, 0), 15, new(0, 0, 1));
var segment = new Segment3d(new(400, 320, 0), new(400, 310, 0));

var intersection = segment.IntersectionWith(circle);
var intersectionSegment = (Segment3d)intersection;

Console.WriteLine(intersectionSegment.ToString());
Console.WriteLine("");
Console.WriteLine($"P1.X: {intersectionSegment.P1.X}");
Console.WriteLine($"P1.Y: {intersectionSegment.P1.Y}");

This prints:

Segment:
Point 1  -> (       400,        310,          0)
Point 2 -> (       400,        315,          0)

P1.X: 25
P1.Y: 0

The output of the ToString() is the result I would expect, but accessing the segment's points (P1 and P2) gives me different values.

It works correctly if I call ConvertTo(null) on the segment's points:

var p1 = intersectionSegment.P1.ConvertTo(null);
Console.WriteLine($"p1.X: {p1.X}");
Console.WriteLine($"p1.Y: {p1.Y}");

Prints:

p1.X: 400
p1.Y: 310

Is it intended to work this way? Intersecting other types (e.g. Segment3d with a Line3d) seems to give me expected results without calling ConvertTo(null).

I'm using version 1.4.0.5 and .NET 8.

Issue with DistanceTo(Point3d p) in particular cases

I noticed an issue when testing the Triangle.DistanceTo(obj) function. It seemed to me that it is a major issue, so I took the time to submit this issue.

From the basic tests i did, it does not work properly if the normal projection of the point on the Triangle.ToPlane belongs to the Triangle.

I don't know if I am clear enough, so i copy pasted a small testing routine that should be explicit enough.

class Testing
{
    public static void Main()
    {

        Point3d p0 = new Point3d(0, 0, 0);
        Point3d p1 = new Point3d(2, 0, 0);
        Point3d p2 = new Point3d(0, 2, 0);
        Point3d pCentre = new Point3d(1, 1, 8);

        Point3d pOnTri1 = new Point3d();
        Point3d pOnTri2 = new Point3d();
        Point3d pOnCir1 = new Point3d();
        Point3d pOnCir2 = new Point3d();

        // plane objects
        Triangle t = new Triangle(p0, p1, p2);
        Circle3d c = new Circle3d(pCentre, 2, new Vector3d(p0, p1));

        // reference point#1 to caclulate the min dist from
        Point3d pRef_1 = new Point3d(1, 1, 4);

        // in this config, should return pRef.Z = 4 
        double dist1_1 = t.DistanceTo(pRef_1); // But returns 0
        // in this config, should return pCentre.Z - c.R ) = 8-2 = 6.  
        double dist2_1 = t.DistanceTo(c, out pOnTri1, out pOnCir1); // but returns 8. pOnTri1 is good, but pOnCir is (1,1,8) instead of (1,1,6)
        // returns '2' as expected 
        double dist3_1 = c.DistanceTo(pRef_1);
        //returns a good closest point,i.e. (1,1,0)
        var closestP1 = t.ClosestPoint(pRef_1);

        // reference point#2 to calculate the min dist from (whith a small offset)
        Point3d pRef_2 = new Point3d(1.00001, 1, 4);
        //returns approx. '4' as expected. If we type (0.00009, 1, 4), it fails again
        double dist1_2 = t.DistanceTo(pRef_2);
        //return a good closest point (1,1,0)
        var closestP2 = t.ClosestPoint(pRef_2);
    }
}

`
For the function t.DistanceTo(Point3D p), I wonder why you do not simply return the length of the Segment3d (p, t.ClosestPoint), as this function seems to work.

Thank you for your feedback.

Can't figure out how to rotate a box

Love your library and am using it quite a lot. I am having an issue rotating a box. What am I doing wrong? I have tried many things. I basically need the box to orient using the three points.

            g.Point3d centerPoint = new g.Point3d(17.2489, 19.8042, -0.307304);
            g.Point3d rightWing = new g.Point3d(17.7258, 19.7956, -0.303844);
            g.Point3d rearward = new g.Point3d(17.26, 19.8038, -0.289645);
            g.Box3d box = new g.Box3d(centerPoint, 0.05, 0.02, 0.01);
            g.Coord3d coord = new g.Coord3d(centerPoint, rightWing, rearward);
            g.Rotation rot = box.Orientation.ConvertTo(coord);
            box = box.Rotate(rot, box.Center);

F# sample

I thought to add F# samples to ReadMe but dotnetfiddle doesn't run code properly due to:

Run-time exception (line -1): That assembly does not allow partially trusted callers.

Stack Trace:

[System.Security.SecurityException: That assembly does not allow partially trusted callers.]
   at <StartupCode$073649e0-01da-4336-a16d-58a9c7937d76>.$4ihoblhi4969.main@()

https://dotnetfiddle.net/kv3ntB

What do you think about adding simple test project into sample folder instead?

How to get coord3D from plane3D ?

Hi,
i have a planed3D (using the a,b,c et d values) and i would like the get a ccord3D where the plane3D is the 0xy plane.
how can i do ?

can not reproduce an example

hi,

i try to reproduce an example in IronPython, however the result is not the same as in original C# examples. Any hints or suggestion?

regards.

import clr
import System
clr.AddReference("GeometRi.dll")
import GeometRi
from GeometRi import *
from System.Math import *


print "Ptolemy's construction of a pentagon"
print "Draw a regular pentagon inside the circle"

O = Point3d(0, 0, 0)
circle = Circle3d(O, 1, Vector3d(0, 0, 1))
C = circle.ParametricForm(0)

l = Line3d(C, O)
CD = l.IntersectionWith(circle)
D = CD.P1

if (D == C):
	D = CD.P2

circle1 = Circle3d(C, CD.Length, circle.Normal)
circle2 = Circle3d(D, CD.Length, circle.Normal)
line = (circle1.IntersectionWith(circle2)).ToLine

AB = line.IntersectionWith(circle)
A = AB.P1
B = AB.P2
M = (O + B) / 2

radius = M.DistanceTo(C);
circle1 = Circle3d(M, radius, circle.Normal);

ON = circle1.IntersectionWith(AB);
N = ON.P1;
if (N == O):
	N = ON.P2
	
side_len = C.DistanceTo(N)
P1 = C

circle1 = Circle3d(C, side_len, circle.Normal)
tmp_segment = circle1.IntersectionWith(circle)
P2 = tmp_segment.P1
P5 = tmp_segment.P2

circle1 = Circle3d(P2, side_len, circle.Normal)
tmp_segment = circle1.IntersectionWith(circle)
P3 = tmp_segment.P1
if (P3 == P1):
	P3 = tmp_segment.P2

circle1 = Circle3d(P3, side_len, circle.Normal)
tmp_segment = circle1.IntersectionWith(circle)
P4 = tmp_segment.P1
if (P4 == P2):
	P4 = tmp_segment.P2

angle1 = Vector3d(P1, P2).AngleToDeg(Vector3d(P1, P5))
angle2 = Vector3d(P2, P1).AngleToDeg(Vector3d(P2, P3))
angle3 = Vector3d(P3, P2).AngleToDeg(Vector3d(P3, P4))
angle4 = Vector3d(P4, P3).AngleToDeg(Vector3d(P4, P5))
angle5 = Vector3d(P5, P4).AngleToDeg(Vector3d(P5, P1))

tolerance = 1e-8; print tolerance
chk1 = Abs(angle1 - 108.0); print chk1
chk2 = Abs(angle2 - 108.0); print chk2
chk3 = Abs(angle3 - 108.0); print chk3
chk4 = Abs(angle4 - 108.0); print chk4
chk5 = Abs(angle5 - 108.0); print chk5

print "Your construction is correct!"
print P1
print P2
print P3
print P4
print P5

and the result is,

>C:\Program Files\IronPython 2.7\ipyw -u "test41.py"
Ptolemy's construction of a pentagon
Draw a regular pentagon inside the circle
1e-08
18.0
18.0
18.0
63.0
63.0
Your construction is correct!
Point3d -> (         0,          1,          0)


Point3d -> (        -1, -2.2204e-16,          0)


Point3d -> (4.4409e-16,         -1,          0)


Point3d -> (         1, 6.6613e-16,          0)


Point3d -> (         1, -2.2204e-16,          0)


>Exit code: 0

ClosestPoint and DistanceTo from point to triangle problem

Hi!
I have some MeshGeometry3D objects with lots of triangles and a Point3D point.
I would like to get the triangles from each Mesh object with the closest distance to the point and I would like to get from the closest distance triangle the closest point.
There seems to be an error in the Triangle.ClosestPoint and therefore in Triangle.DistanceTo aswell.

After I calculate the closest triangles of all the sub models and get the closest points, I draw these and the result is not what I expect.
The black lines should be the lines from the given point to the closest points of golden triangles.
I would appreciate if you helped me with this...

If it is not clear enough I will create a demo app.

Thank you!
Tamás
Hiba1

Unexpected results with large dimention geometries

Hello there,

I noticed pretty critical unexpected results when large dimension objects are manipulated.
For more details and documentation, see code below (unit test functions).
I do hope that I am clear enough. I am not an experienced developer, and more an engineer that tries to develop and to give feedback as clean as possible.

I am aware that the tolerance parameter can be a way to kind of solve the issue, but for my use, i do need a pretty fine tolerance, while manipulating significantly "big" geometrical objects.

  1. I already took a look into the GeometRi functions. For the Triangle Intersection error (see public void testTriangleIntersection()), i do not have any clue yet about where the issue comes from.
  2. For the Coplanar error (see testCoplanar()), I think I found where it comes from (see below)
using Microsoft.VisualStudio.TestTools.UnitTesting;


namespace Namespace   

 [TestClass]
    public class TestHighNumberTolerances
    {
        [TestMethod]
        public void testTriangleIntersection()
        {
            Point3d a = new Point3d(18508, 7020, 3193);
            Point3d b = new Point3d(-925, -162, -233);
            Point3d c = new Point3d(-858, -349, -221);

            Triangle t = new Triangle(a, b, c);

            Plane3d plane = new Plane3d(new Point3d(0, 200, 0), new Vector3d(0, 1, 0));

            Segment3d s0 = new Segment3d(a, b);
            Segment3d s1 = new Segment3d(a, c);


            object result = t.IntersectionWith(plane); //while we expect a segment3d, it can be null, or point3d like here

            object inter1 = s0.IntersectionWith(plane); //returns Point3d
            object inter2 = s1.IntersectionWith(plane);//returns another distinct Point3d 
            Segment3d expectedResult = new Segment3d((Point3d)inter1, (Point3d)inter2); //segment3d with a >0 length

            Assert.IsTrue(expectedResult.Equals(result)); //Error
        }

        [TestMethod]
        public void testCoplanar()
        {
            Point3d a = new Point3d(-1000, 180, -70);
            Point3d b = new Point3d(20000, 180, -70);
            Point3d c = new Point3d(20000, 180, 70);
            Point3d d = new Point3d(-1000, 180, 70);

            Triangle t0 = new Triangle(a, b, c);
            Triangle t1 = new Triangle(b, c, d);

            Rotation rz = new Rotation(Coord3d.GlobalCS.Zaxis, 30 * System.Math.PI / 180);
            Rotation ry = new Rotation(Coord3d.GlobalCS.Yaxis, 10 * System.Math.PI / 180);

            Point3d p = new Point3d(0, 0, 0);

            t0 = t0.Rotate(rz, p);
            t1 = t1.Rotate(rz, p);
            t0 = t0.Rotate(ry, p);
            t1 = t1.Rotate(ry, p);

            bool areEqual = t0.ToPlane.Equals(t1.ToPlane); //returns false (expected true)
            bool areCoplanar = t0.IsCoplanarTo(t1);//returns false (expected true)
            Assert.IsTrue(areEqual); //Error
            Assert.IsTrue(areCoplanar); //Error

            bool areEqual_fix = t0.ToPlane.Equals_fix(t1.ToPlane); //returns true
            bool areCoplanar_fix = t0.IsCoplanarTo_fix(t1); //returns true
        }

        public static bool Equals_fix(this Plane3d p0, Plane3d p1)
        {
            bool isCoplanar;
            if (p1.Normal.IsParallelTo(p0.Normal))
            {
                if (p1.Point.Equals(p0.Point))
                    isCoplanar = true;
                else
                {
                    var v = new Vector3d(p1.Point, p0.Point).Normalized;
                    double a = v.Dot(p0.Normal.Normalized);
                    isCoplanar = a <= GeometRi3D.DefaultTolerance;
                }
            }
            else
                isCoplanar = false;
            return isCoplanar;
        }

        public static bool IsCoplanarTo_fix(this IPlanarObject p1, IPlanarObject p2)
        {
            return p1.ToPlane.Equals_fix(p2.ToPlane);
        }

The "IsCoplanar" issue comes in my opinion from these lines (Point3d), with the square root that makes the result to quickly exceed the GeometRi3D.Tolerance.

public bool BelongsTo(Plane3d s)
        {
            s.SetCoord(Coord);
            if (GeometRi3D.UseAbsoluteTolerance)
            {
                return Math.Abs(s.A * X + s.B * Y + s.C * Z + s.D) / Math.Sqrt(s.A * s.A + s.B * s.B + s.C * s.C) < GeometRi3D.Tolerance;
            }

            double num = DistanceTo(_coord.Origin);
            if (num > 0.0)
            {
                return Math.Abs(s.A * X + s.B * Y + s.C * Z + s.D) / Math.Sqrt(s.A * s.A + s.B * s.B + s.C * s.C) / num < GeometRi3D.Tolerance;
            }

            return Math.Abs(s.A * X + s.B * Y + s.C * Z + s.D) / Math.Sqrt(s.A * s.A + s.B * s.B + s.C * s.C) < GeometRi3D.Tolerance;
        }

The IsEqual Issue comes in my opinion from these lines (Point3d), because the distance exceed the Tolerance.

        public double DistanceTo(Line3d l)
        {
            return new Vector3d(this, l._point).Cross(l._dir).Norm / l._dir.Norm;
        }

Instead, it would be clever to use the logical functions that are based as often as possible on normalized logics that allow us to avoid as mush as possible to use very big (or also very small) double values (see my proposals for the functions "IsCoplanar_Fix" ans "Equals_fix".


In general, I would highly suggest that the IPlanarObject.Normal, ILinearObject.Direction (and so on) should be Normalized vector only.
Also, in many functions too we are manipulating non Normalized vectors then it could be. This is in my opinion often not coherent with the notion of Tolerance, especially when talking about Vector3d.Cross(vector3d) or vector3d.Dot(vector3d).

For instance, when, we are checking if two lines are crossing, it does not matter how these lines have been created. After the line creation, we Have a Point3d, and a Vector3d Direction. Sadly this Direction is not Normalized, and it leads to an isue with these lines :

 public virtual Point3d PerpendicularTo(Line3d l)
        {
            Vector3d toVector = Point.ToVector;
            Vector3d toVector2 = l.Point.ToVector;
            Vector3d direction = Direction;
            Vector3d direction2 = l.Direction;
            if (direction.Cross(direction2).Norm > GeometRi3D.Tolerance)
            {
                toVector = toVector2 + (toVector2 - toVector) * direction.Cross(direction.Cross(direction2)) / (direction * direction2.Cross(direction.Cross(direction2))) * direction2;
                return toVector.ToPoint;
            }

            return l.Point;
        }

Multiple .Cross functions induce wrong results with big double values, where it could be easily right considering normalized vectors.

Please ask if you need help or further testings.
Regards, and thank you by advance.

Segment3d problem with ClosestPoint to a Point3d

Hi Sergey,
I have run into a problem when I was calculating closest points on segments from a given point. I discovered that sometimes I get different result if I change the order of P1 and P2 when instantiating a Segment3d.
If I run the code below I wait that dst1 and dst2 should be the same and cp1 and cp2 also, but they are not!

var p1 = new Point3d(23179.004, 12816.489, -20.395);
var p2 = new Point3d(22563.294, 13022.342, 90.848);
var sg1 = new Segment3d(p1, p2);
var sg2 = new Segment3d(p2, p1);
var pnt = new Point3d(23036.287595521906, 12779.633961461441, -5.2532084155503256);

var dst1 = sg1.DistanceTo(pnt);
var dst2 = sg2.DistanceTo(pnt);
var cp1 = sg1.ClosestPoint(pnt);
var cp2 = sg2.ClosestPoint(pnt);

Would you check this and tell me if I do something wrong?
Thank you very much!
Tamás

Update:
If I set GeometRi3D.UseAbsoluteTolerance = false; then the results are good. If I divide all coordinates by 1.000, then the results are good (without setting UseAbsoluteTolerance to false).
By default the tolerance is 1E-12. If I set it to 1E-24 then the results are the same but they are wrong. If I set the Tolerance to 1E-9 then the results are good.
I am confused.

Point3d within Triangle is considered to be some distance away

Point3d instances that are clearly part of a Triangle are sometimes considered to be some distance away when using Point3d.DistanceTo(Triangle t) or Triangle.DistanceTo(Point3d p).

Example:

var triangle = new Triangle(
    new Point3d(0, 0, 0),
    new Point3d(10000, 0, 0),
    new Point3d(0, 10000, 0));

var point = new Point3d(3286.5999999974479, 5000, 0);

double distance = triangle.DistanceTo(point);   // Expected: 0, Actual: 1211.55...

Sample code used to produce the above point:

double size = 10000;
double step = size / 100000;
double p = size / 2;

Triangle triangle = new Triangle(
    new Point3d(0, 0, 0),
    new Point3d(size, 0, 0),
    new Point3d(0, size, 0));

for (double px = p; px > 0 ; px -= step)
{
    Point3d point = new Point3d(px, p, 0);
    double distance = triangle.DistanceTo(point);

    if (distance > GeometRi3D.Tolerance)
    {
        throw new Exception("Point that is part of triangle is considered to be some distance away");
    }
}

Triangle.DistanceTo(Point3d p) is fixed to usage of absolute tolerances. Triangle._PointLocation(Point3d p) does not consider its calculation to be almost equal, when using absolute tolerances, finally resulting in a calculation to the closest edge in Triangle.DistanceTo(Point3d p).

The calculation with relative tolerances in Triangle._PointLocation(Point3d p) does consider the point to be within the triangle. But this calculation will never be used.

Might be related to issues posted by @AntoineC4Ci

It would be nice to have a method for a Box3d if a given triangle or a part of the triangle is in the Box3d

Hi,
I am working with meshes (objects built from lots of triangles) and have to determine the intersection of two meshes.
I try to divide the space to smaller and smaller cubes and check if a cube intersects any triangle from both meshes. If the edge of a cube is less than a predefined small number, than I assume that the two meshes intersect at the cube.
For this I need a method that checks if a given triangle is intersecting (or the whole triangle is inside) the space of the Box3d.
If you don't have time to write this method, would you give me any suggestions how to solve it?
Thank you!

3d Triangle to Triangle intersection errors

Hello, I tried to use the 3d triangle to triangle intersection algorithm to make a reliable 3d triangle mesh intersection algorithm but started getting errors while trying to intersect some triangles. I had to implement it with another library but it would be great to have it work with this library which I believe is very well structured. I believe the exception was generated was generated when two triangles shared a side or a vertex.

Segment Intersection not working properly

Hi,

I am performing 3d segment intersections but am getting inconsistent results in some cases where small precision errors generate tiny differences. Interestingly, intersecting in one direction works, and intersecting in the opposite direction doesn't.

Example:

intersectSegment.IntersectionWith(lineSeg3d)
null
lineSeg3d.IntersectionWith(intersectSegment)
Segment:
Point 1 -> ( 399.83, 255.06, 0)
Point 2 -> ( 421.64, 255.06, 0)

ADDITIONAL INFO

intersectSegment.ToString()
"Segment:
Point 1 -> ( 399.83, 255.06, 0)
Point 2 -> ( 453.16, 255.06, 0)"
lineSeg3d.ToString()
"Segment:
Point 1 -> ( 389.99, 255.06, 0)
Point 2 -> ( 421.64, 255.06, 0)"
intersectSegment.ToLine.DistanceTo(lineSeg3d.ToLine)
0
intersectSegment.Direction.Normalized
Vector3d -> ( 1, 1.279e-14, 0)
lineSeg3d.Direction.Normalized
Vector3d -> ( 1, -3.5925e-15, 0)

Point3d ConvertTo issue

Point3d.ConvertTo doesn't return converted one for globally defined point but Point3d.ToString(Coord3d coord) gives the desired result for a local coordinate

Can you help about this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.