+ Reply to Thread
Results 1 to 4 of 4

Thread: Need help with calculating velocity of a vector

  1. #1
    Wire Amateur ace1313's Avatar
    Join Date
    Feb 2007
    Posts
    81

    Default Need help with calculating velocity of a vector

    I've been playing with the idea of having a drone above your head, resulting in this expression:

    Code:
    @name Evil Hyvel
    
    interval(10)
    EE=entity(),EA=EE:angVel()
    EV=EE:pos(),EU=EE:up()
    TV = entity():owner():pos() + vec(0,0,150) + entity():owner():vel()/8
    TL = entity():owner():aimPos()
    
    #Forces
    applyForce((TV-EV-EE:vel()/10)*entity():mass()) #Above head
    applyOffsetForce((TL-TV)/1000, EV+EU) #Aim, needs some sort of delta
    applyOffsetForce(-(TL-TV)/1000, EV-EU)} #Aim, needs some sort of delta
    The problem is that I have no idea to check the velocity of EE:up(), so it wobbles more and more until it's just spinning randomly

  2. #2
    Wire Sofaking mjmr89's Avatar
    Join Date
    Mar 2008
    Posts
    555

    Default Re: Need help with calculating velocity of a vector

    Not quite sure what you're asking here. There's a function E:velL() that returns the vector of the speed relative to the entity, I think E:velL():z() would give you the up/down velocity of the entity.

  3. #3
    Wire Amateur ace1313's Avatar
    Join Date
    Feb 2007
    Posts
    81

    Default Re: Need help with calculating velocity of a vector

    I want to get the velocity of entity():up(), not the Z velocity

  4. #4
    Expressionism 2.0 Syranide's Avatar
    Join Date
    Mar 2007
    Location
    Sweden
    Posts
    4,573

    Default Re: Need help with calculating velocity of a vector

    Delta works on vectors.

    Code:
    if(entity():up() != Up) {
        Up = entity():up()
        Velocity = $Up
    }
    However, know that the vector doesn't become properly interpolated, so you need to normalize it yourself to get somewhat proper readings.

    ... BUT, I'd say it is far better to use the velocity() (and angular velocity) functions for the entity(), they are more accurate and basically better in every way.

+ Reply to Thread

Similar Threads

  1. Help on calculating 3d distances
    By lucasmontec in forum Installation and Malfunctions Support
    Replies: 12
    Last Post: 03-09-2009, 12:48 PM
  2. Need Help Calculating Yaw & Pitch From 2 XYZ coordinates
    By Meatloaftwo in forum Installation and Malfunctions Support
    Replies: 16
    Last Post: 10-20-2008, 10:19 AM
  3. Calculating Bearing, Elevation, and Distance with vectors
    By GhostMX in forum Installation and Malfunctions Support
    Replies: 8
    Last Post: 08-11-2008, 02:20 PM
  4. Calculating bearing?
    By thesage1014 in forum Installation and Malfunctions Support
    Replies: 7
    Last Post: 08-19-2007, 11:32 PM
  5. Calculating Bearing and Elevation from GPS co-ords
    By MistaGiggles in forum Installation and Malfunctions Support
    Replies: 4
    Last Post: 06-06-2007, 12:41 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
proceed-collector
proceed-collector
proceed-collector
proceed-collector
linguistic-parrots
linguistic-parrots
linguistic-parrots
linguistic-parrots