Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 57049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T17:37:49+00:00 2026-05-10T17:37:49+00:00

I’ve been playing with some algorithms on the internet for a while and I

  • 0

I’ve been playing with some algorithms on the internet for a while and I can’t seem to get them to work, so I’m tossing the question out here;

I am attempting to render a velocity vector line from a point. Drawing the line isn’t difficult: just insert a line with length velocity.length into the graph. This puts the line centered at the point in the y-axis direction. We need to get this now in the proper rotation and translation.

The translational vector is not difficult to calculate: it is half the velocity vector. The rotational matrix, however, is being exceedingly elusive to me. Given a directional vector <x, y, z>, what’s the matrix I need?

Edit 1: Look; if you don’t understand the question, you probably won’t be able to give me an answer.

Here is what I currently have:

                    Vector3f translation = new Vector3f();                     translation.scale(1f/2f, body.velocity);                      Vector3f vec_z = (Vector3f) body.velocity.clone();                     vec_z.normalize();                      Vector3f vec_y; // reference vector, will correct later                     if (vec_z.x == 0 && vec_z.z == 0) {                         vec_y = new Vector3f(-vec_z.y, 0f, 0f); // could be optimized                     } else {                         vec_y = new Vector3f(0f, 1f, 0f);                     }                     Vector3f vec_x = new Vector3f();                     vec_x.cross(vec_y, vec_z);                     vec_z.normalize();                      vec_y.cross(vec_x, vec_z);                     vec_y.normalize();                     vec_y.negate();                      Matrix3f rotation = new Matrix3f(                         vec_z.z, vec_z.x, vec_z.y,                         vec_x.z, vec_x.x, vec_x.y,                         vec_y.z, vec_y.x, vec_y.y                     );                      arrowTransform3D.set(rotation, translation, 1f);

based off of this article. And yes, I’ve tried the standard rotation matrix (vec_x.x, vec_y.x, etc) and it didn’t work. I’ve been rotating the columns and rows to see if there’s any effect.

Edit 2:

Apologies about the rude wording of my comments.

So it looks like there were a combination of two errors; one of which House MD pointed out (really bad naming of variables: vec_z was actually vec_y, and so on), and the other was that I needed to invert the matrix before passing it off to the rendering engine (transposing was close!). So the modified code is:

                    Vector3f vec_y = (Vector3f) body.velocity.clone();                     vec_y.normalize();                      Vector3f vec_x; // reference vector, will correct later                     if (vec_y.x == 0 && vec_y.z == 0) {                         vec_x = new Vector3f(-vec_y.y, 0f, 0f); // could be optimized                     } else {                         vec_x = new Vector3f(0f, 1f, 0f);                     }                      Vector3f vec_z = new Vector3f();                     vec_z.cross(vec_x, vec_y);                     vec_z.normalize();                      vec_x.cross(vec_z, vec_y);                     vec_x.normalize();                     vec_x.negate();                      Matrix3f rotation = new Matrix3f(                         vec_x.x, vec_x.y, vec_x.z,                         vec_y.x, vec_y.y, vec_y.z,                         vec_z.x, vec_z.y, vec_z.z                     );                     rotation.invert();
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T17:37:50+00:00Added an answer on May 10, 2026 at 5:37 pm

    Dupe.

    The question there involves getting a rotation to a certain axis, whereas I’m concerned with getting a rotation matrix.

    Gee, I wonder if you could turn convert one to the other?

    BTW, your current solution of picking an arbitrary y axis and then reorthogonalising should work fine; it looks bugged though, or at least badly written. ‘z_vec‘ is not a good variable-name for the y-axis. What’s with the ‘z,x,y’ ordering, anyway?

    If it still doesn’t work, try making random changes until it does – transpose the matrix, negate vectors until you have an even number of sign errors, that kind of thing.

    Also your tone of voice comes across as sort-of rude, given that you’re asking strangers to spend their time helping you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 103k
  • Answers 103k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer django-transaction-hooks solves this problem for Django < 1.9, and the… May 11, 2026 at 8:29 pm
  • Editorial Team
    Editorial Team added an answer array.Contains("str", StringComparer.OrdinalIgnoreCase); Or depending on the specific circumstance, you might… May 11, 2026 at 8:29 pm
  • Editorial Team
    Editorial Team added an answer There is no DDL trigger for RESTORE, there is however… May 11, 2026 at 8:29 pm

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am currently running into a problem where an element is coming back from
Seemingly simple, but I cannot find anything relevant on the web. What is the
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.