Overkillz Posted November 1, 2019 Share Posted November 1, 2019 Hello dear community, Im haivng an issue which is giving me some troubles. Im trying to project a line 3D between 2 points, the vehicle which is on the air and the ground. Here is an example how it is drawn and how it is supposed to be drawn (WHITE line is how it is drawn and RED Line is how it should be drawn ) Spoiler Sadly, I can't figure out how to use the proper maths here. local x,y,z = getElementPosition(theVehicle) local rx,ry,rz = getElementRotation(theVehicle) local ground = getGroundPosition(x,y,z) dxDrawLine3D(x,y,z,x+rx,y+ry,ground) I hope you can bring me a hand with this problem Thanks in advance, regards. Link to comment
Discord Moderators Zango Posted November 2, 2019 Discord Moderators Share Posted November 2, 2019 What are you trying to do with this? If you're looking to create a line that is always perpendicular to the vehicle then you can use getElementMatrix local x1, y1, z1 = getElementPosition(theVehicle) local m = getElementMatrix(theVehicle) local x2 = -100 * m[3][1] + m[4][1] local y2 = -100 * m[3][2] + m[4][2] local z2 = -100 * m[3][3] + m[4][3] dxDrawLine3D(x1, y1, z1, x2, y2, z2) -100 is the length of the projected line, you can use processLineOfSight to find whatever it collides with. Link to comment
Overkillz Posted November 2, 2019 Author Share Posted November 2, 2019 @Zango Thanks for your help. Yes, I had been looking for creating a line which was orthogonal to the vehicle. However, Im so curious. I already see that with the Matrix you can get the rotation, offset ...etc of an element. However, there are somo arrays that I cant figure out how to deal with them. For what is used each array ? If you can clear me this question. Thanks for reading, regards. Link to comment
Discord Moderators Zango Posted November 2, 2019 Discord Moderators Share Posted November 2, 2019 You can search for better explanations on that than I can give you, read about what a translation matrix is and then a rotation matrix afterwards Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now