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

  • SEARCH
  • Home
  • 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 6330267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:50:25+00:00 2026-05-24T17:50:25+00:00

I have a short method in my code to normalize a vector (actually a

  • 0

I have a short method in my code to normalize a vector (actually a PCL point) which produces results of low accuracy. The code:

void normalize(pcl::PointXYZ::PointXYZ * p){
  float nf = 1/sqrt(p->x*p->x+p->y*p->y+p->z*p->z);
  //nf is a normalization factor precalculated to eliminate two FP divisions.
  p->x*=nf; p->y*=nf; p->z*=nf;
}

This function is passed the point with coordinates (-0.850650787, 1.37638187, -0.525731087). Debugging shows that nf=0.587785244 after evaluation of the second line. When I do the same calculation in Mathematica, nf=0.617708029. This is an error of more than 5%! The coordinates of p are never greater than 2 or less than -2. Is this inaccuracy typical for these operations, or is there something wrong?

  • 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. Editorial Team
    Editorial Team
    2026-05-24T17:50:26+00:00Added an answer on May 24, 2026 at 5:50 pm

    According to my calculations, 0.587785244 is the correct result (I get 0.5877852727698576 using Perl). I suspect you’re doing the calculation incorrectly in Mathematica.

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

Sidebar

Related Questions

Does anybody have a short code sample that can be run in the VS
I have a short preliminary interview with Microsoft in less than 2 hours. I've
I have a short program that is used exclusively with a remote desktop connection
So I have about 10 short css files that I use with mvc app.
I wish to have long and short forms of command line options invoked using
To make a long story short I have to use processing in a class
I'm just getting into unit testing, and have written some short tests to check
I have a bunch of short videos from my digital cam. i know how
I have an array of shorts (short[]) that I need to write out to
When using something like object.methods.sort.to_yaml I'd like to have irb interpret the \n characters

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.