Menu

Distance between points in the screen

Help
Sergio
2017-05-24
2017-05-24
  • Sergio

    Sergio - 2017-05-24

    I need to create a methiod to click in two points of the scene and getting the distance between then. Do you know any demo or code for this ? Thanks in advance

     
  • Jerome.D (BeanzMaster)

    Hi Sergio you can take a look at the
    \Samples\collisions\meshhit for selecting points
    Samples\collisions\RayBox for intersecting
    and for calculate distance you have this :

    { Calculates distance between two vectors.
       ie. sqrt(sqr(v1[x]-v2[x])+...) }
    function VectorDistance(const v1, v2 : TAffineVector): Single; overload;
    { Calculates distance between two vectors.
       ie. sqrt(sqr(v1[x]-v2[x])+...) (w component ignored) }
    function VectorDistance(const v1, v2 : TVector): Single; overload;
    
    { Calculates the "Norm 2" between two vectors.
       ie. sqr(v1[x]-v2[x])+... }
    function VectorDistance2(const v1, v2 : TAffineVector): Single; overload;
    { Calculates the "Norm 2" between two vectors.
       ie. sqr(v1[x]-v2[x])+... (w component ignored) }
    function VectorDistance2(const v1, v2 : TVector): Single; overload; 
    

    in GLVectorGeometry.Pas and some others useful functions :)

    You have also 2 or 3 samples in GLSAsm repo there can help you but not rememeber what they are.

    (ouch not sur it's a good english sentence, sorry )

     
  • Sergio

    Sergio - 2017-05-24

    Thanks Jerome. Reading your text I remebered something . Click the screen >>> Ponit to Vector and then VectorDistance / Vector Subtract

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.