Map a point within a triangle from low dimensions to high

21 Apr 2012 . category: . Comments

The work I have been doing recently is to explore a mapping from a low dimensional space(10d) to a high dimensional space(160d). Although is not a particularly common problem is something that requires a little thinking.

The obvious solution is to measure the distance, from the point to the three, triangle points. This of course is difficult to rationalise to a ratio that sums to 1.

Barycentric-BasicMapping

This problem becomes more obvious when a point lies on one of the points on the triangle. For example, this could result in a distance of [0, 50 50]. This distance means that if you project this using this information even if normalised, the point will not lie on the triangle coordinate in the higher dimensional space.

To be able to map between two triangles accurately the best solution is to utilise Barycentric coordinates. This turns the 3 points of the triangle into three vertices. Using this information you are then able to solve to find the ratios to accurately map between the two spaces.

Barycentric-Mapping

Therefore to generate a new point in 2D, you have:

To get to this point we need to solve the equations for lambda, resulting in n equations for each of the different dimensions.

This can be solved relatively easily using a linear solver.

So now using this information it is easy to project the point from one triangle to the other. We have provided a Matlab solution to be able to easily map using two triangles.

1 A = []; 2 B = [] ; 3 for i=1:size(ntA,1) 4 line = [(ntA(i,1) - ntA(i,3)) (ntA(i,2) - ntA(i,3)) ]; 5 B = [ B ; (ntA(i,3) - Qn(i)) ] ; 6 A = [A ; line]; 7 end 8 Lambda = linsolve(A,-B);

Therefore you can map the new point using

1 Lambda = [Lambda ; ( 1 - Lambda(1) - Lambda(2) )]; 2 3 pB = sum(tB .* repmat(Lambda',[],size(tB,1)),2);

 

You can view a complete version of this code, as well as a test case Files.

See: Files –>  Barycentric Coordinates

Equations thanks to the ever wonderful Wikipedia


Stuart James  


Stuart James

Assistant Professor in Visual Computing at Durham University. Stuart's research focus is on Visual Reasoning to understand the layout of visual content from Iconography (e.g. Sketches) to 3D Scene understanding and their implications on methods of interaction. He is currently a co-I on the RePAIR EU FET, DCitizens EU Twinning, and BoSS EU Lighthouse. He was a co-I on the MEMEX RIA EU H2020 project coordinated at IIT for increasing social inclusion with Cultural Heritage. Stuart has previously held a Researcher & PostDoc positions at IIT as well as PostDocs at University College London (UCL), and the University of Surrey. Also, at the University of Surrey, Stuart was awarded his PhD on visual information retrieval for sketches. Stuart holds an External Scientist at IIT, Honorary roles UCL and UCL Digital Humanities, and an international collaborator of ITI/LARSyS. He also regularly organises Vision for Art (VISART) workshop and Humanities-orientated tutorials and was Program Chair at British Machine Conference (BMVC) 2021.