## How to calculate consistent signed Normal of Triangle?

I am currently calculating normals for 3 point coplanar triangles like P1, P2, P3

$$N = (P1 – P2) \times (P2 – P3)$$

This equation will give me different negative or positive Normal depending on the order of the points.

  const N = getNormalForTriPoints(p1,p2,p3); //1   const N = getNormalForTriPoints(p2,p1,p3); // -1 

I am using this function in a collision detection algorithm and feeding it a set of world space triangles. The normal calculation is causing unexpected results like falling through objects because the normals are reversed. If I can’t calculate a normal reliably what alternatives do I have to handle this? How do I know what order to feed in the triangles? Or what methods are available to sort the triangles?

## Calculate number of triangle that can be formed by joining special nodes in a tree

Problem source : CHGORAM2 Problem : A tree is given to us and it’s nodes are marked as 1 or 0 . We need to calculate how many triplets (x,y,z) can be formed such that node x,y,z are marked as 1 and distance(x,y) = distance(y,z) = distance(z,x) .Here distance(x,y) denotes distance between node x and y.Also x,y,z need to be distinct.

I am only able to solve it using brute force . But Editorial mentions some O(n) solution which i did not understood.

## triangle inequality TSP is NP-complete?

I have been reading online source and it mentioned triangle inequality TSP is NP-complete but without proof. In general, the reduction from HAM-cycle problem to TSP works for asymmetric and symmetric TSP problem. So, I wonder how to start a basic approach to prove triangle inequality TSP is NP-complete.

## Counter example to Zooko’s triangle? [on hold]

So Zokoo’s triangle is a conjecture that is often explained by this trilemma:

Names:

-secure

-distributed

-human-meaningful

pick two

But what if we hash the public key of an user and turn it into a meaningful identifier?

For example, we can use the hash as an input to get an unique profile picture with Gravatar (the default profile picture generator of Stack Exchange). We can also pass the hash as a seed to a neural network that generates profile pictures with people, animals, landscapes, etc.

But that’s not good, we can’t fetch an user identified by their profile picture, so we have to create meaningful character strings. I call it the “exquisite corpse” method: Let’s say the hash contains 6 alphanumerical characters, we can divide it into 3 parts of 2 characters each. The first part identifies an adverb in a dictionary of 3844 words ((26*2+10)²), the second part identifies an adjective is a dictionary of 3844 words and the third part a noun in a dictionary of 3844 words. This way, we obtain usernames like Extremely Metaphorical Chicken.

Maybe you would say that relying on a common arbitrary dictionary of words makes it not distributed, but in this case the arbitrary choice of the hash function would also make it not distributed. The ‘distributed’ criterion means that every peer on the network can do name resolve by themselves, not that we can’t rely on a common standard. Every peer can download the dictionary and/or the Gravatar generator (although I concede installing a whole neural network would be too much).

Is it a proper counter-example to Zooko’s triangle or I am mistaken? If so, should we change “human-meaningful” to “human-choosable”?

## to do a triangle [on hold]

this is my code

class Pattern {     public static void main (String [] args)         {         int STAR = "*";         int SPACE = " ";         int HEIGHT = 5;          {              Display();              console.ReadLine();              {               static public void  Display()                  {                      for (int i = 0; i < HEIGHT; i++)                      {                          for (int j = 0; j < i; j++)                          console.write(SPACE);                           for (int j = 0; j < HEIGHT; j++)                          console.Write(STAR);                          console.WriteLine();                      }                  }              }          }     } } 

my errors are this

Pattern.java:12: error: illegal start of expression static public void Display()

Pattern.java:25: error: class, interface, or enum expected }

## Triangle solutions by projection on plane!

I have a little question. how many solutions has a triangle by the projection on the plane? Like the Patenoth problem but in 3d space.

## Find a length in an equilateral triangle [on hold]

I have an equilateral triangle ABC. There is a point D in the triangle. And AD=3, BD=4 and I want to find the length of CD. I tried law of cosines that didn’t help me and I tried to find area for those 3 little triangles. No result. Do you have any suggestions? I’ll appreciate it

## Intersection of sphere with triangle containing moving vertices

First off, apologies if I cannot properly articulate my question in the most formal way. However, I believe my question should be simple enough to grasp anyhow.

In $$\mathbb{R}^3$$, I would like to determine the time of contact, if any, between:

• An unmoving unit sphere, whose center is at the origin
• A triangle, each of whose vertices follow independent, linear motion from $$t = 0$$ to $$t = 1$$. In other words, each triangle vertex has a start and end position, which are linearly interpolated by $$t$$.

The sphere may touch the triangle on a vertex, an edge, or on the triangle’s surface. Vertex testing is simple enough as it’s analogous to static line segment-sphere intersection.

For edge testing, parameterizing a line-sphere intersection test by $$t$$ appaers to lead to solving a degree 4-polynomial, which isn’t ideal. I believe that doing the same for triangle surface testing (parameterizing a sphere-plane intersection with $$t$$) would lead to solving a 6-degree polynomial.

Would there be any applicable non-analytical methods to approximate the intersection (other than directly approximating the polynomial roots)? Or maybe there is an analytical method that I’m not thinking of. In addition, would further constraining the motion of the triangle potentially simplify a solution?

## Small triangle appear when changing the edge labelling in tikz

By changing the labelling of the edges between nodes, there are some small triangle appearing.

Unwanted triangles

The code producing this issue:

\path[draw, ->] (1.60) edge node [above left] {12} (2.210); \path[draw, <-] (1.30) edge node [below right] {4} (2.240); 

## divide and conquer algorithm for finding a 3-colored triangle in an undirected graph with the following properties?

In an undirected Graph G=(V,E) the vertices are colored either red, yellow or green. Furthermore there exist a way to partition the graph into two subsets so that |V1|=|V2| or |V1|=|V2|+1 where the following conditions apply: either every vertex of V1 is connected to every vertex of V2 or no Vertex of V1 is connected to a vertex of V2 . This applies recursively to all induced subgraphs of V1 and V2

I can find all triangles in the Graph by multiplying the adjacency matrix with itself three times and step up the nodes corresponding to the non zero entries of the main diagonal. Then I can see if the nodes of the triangle are colored the right way. O(n^~2,8)! But given the unique properties of the graph I want to find a solution using divide and conquer to find the colored triangle. this is an example graph with the given properties. I need to find the bold triangle:

Blue boxes symbolize the partitions are fully connected, purple boxes mean no connection between the partitions There is no connection between the coloring of nodes and the partitions, also the partitions have to be computed on the fly