1

How do i calculate point D for triangle 2?

I have the the following coordinates for triangle 1: a(0,0) b(0,78) c(18,39)

point D is located at (0,39) in triangle 1.

now I change the perspective on my triangle by for example moving coordinate b and c. the new triangle formed is called triangle 2 with coordinates: a(0,0) b(11,72) c(37,42)

AS YOU CAN SEE POINT D IS NOT IN THE MIDDLE OF LINE a<-->b BECAUSE OF THE CHANGE IN PERSPECTIVE/SKEW.

How do i calculate point d? I have the coordinates abc of triangle 1 & 2.

Preferably answer in programcode rather than using math signs, since i am not a hero at reading math :)

fellowworldcitizen
  • 3,441
  • 3
  • 15
  • 17
  • Welcome to stackoverflow. Pure code-writing requests are off-topic on Stack Overflow - but we will happily help you write it yourself! Tell us [what you've tried](http://whathaveyoutried.com) – rob mayoff Aug 08 '12 at 08:01
  • Toe be fair, @robmayoff I think that was less of a "JST GIV ME T3H CODEZ PLZ!!!!!11!!" request than a "Understanding Mathematical symbols can be difficult for me, so please represent your answer in a way I can understand." request. – Zéychin Aug 08 '12 at 08:38
  • @Zéychin I agree, but I think the general philosophy on stackoverflow is that an asker should try *something* and post what he tries, instead of just asking without trying. Also, if fellowworldcitizen wants to do this kind of programming, he's going to have to practice reading math. – rob mayoff Aug 08 '12 at 08:42
  • @robmayoff Thanks for answering something to get me further. Believe me i have been trying! – fellowworldcitizen Aug 08 '12 at 09:38

2 Answers2

1

You need to convert point D to barycentric coordinates using the original triangle coordinates, then convert it back to cartesian coordinates using the modified triangle coordinates.

This looks like a good introduction to triangular barycentric coordinates: http://blogs.msdn.com/b/rezanour/archive/2011/08/07/barycentric-coordinates-and-point-in-triangle-tests.aspx

Also, explicit formulae for converting a point in a triangle to barycentric coordinates are given at the end of the Converting to Barycentric Coordinates section of the Wikipedia article “Barycentric coordinate system”.

rob mayoff
  • 375,296
  • 67
  • 796
  • 848
  • i think i need to first find the cameraview coordinates (x,y,z) before i am able to calculate point D. how can i determine the camera's point of view based on the coordinates a,b and c? – fellowworldcitizen Aug 08 '12 at 11:06
0

I guess there are more ways of calculating a coordinate from one perspective to another.

more on the triangle way is written by culebrón here: Transforming captured co-ordinates into screen co-ordinates

At the same link there is another way by using SVD and calculate an H-matrix which can be used to translate any coordinate from one perspective to another. I am going to use this way because i could solve this way in matlab. Next step in objective-c! i had some trouble calculating the same in objective-c. more on that here: calculate the V from A = USVt in objective-C with SVD from LAPACK in xcode

I would like to know how to solve the triangle way too! i could not figure out what a1 and a2 were in culebron's post: https://stackoverflow.com/a/1690300/1568532 neither the width and height made much sense to me.

Also i would like to know how to calculate the EYE's point of view on a triangle or quadrangle based on 3 or 4 coordinates. if you know the original size of the object. any ideas on this?

when i search for eye or camera's point of view. there is load of result about photography. what do i need to use in order to calculate this? maybe some example anyone?

Community
  • 1
  • 1
fellowworldcitizen
  • 3,441
  • 3
  • 15
  • 17