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 8542369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:03:00+00:00 2026-06-11T12:03:00+00:00

I am currently making a program to build up and knock down blocks. It’s

  • 0

I am currently making a program to build up and knock down blocks. It’s simple but fun. I have gotten pretty far but have hit a snag.

So far, I have it so that when I click, it creates a block at the position I am looking at, either on another block or the ground. This is achieved through the use of ray tracing from the camera and creating a block at a Vector3F created from the collision between the ray and the other object. What I can’t do is round the Vector3F so that the numbers are all single digit integers. Does anyone know how to achieve this?

  • 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-06-11T12:03:02+00:00Added an answer on June 11, 2026 at 12:03 pm

    You can use Math.round():
    http://docs.oracle.com/javase/6/docs/api/java/lang/Math.html#round(float)

    Examples:
    1:

    // It will round the floats in Vector3F and leave the results as floats
    Vector3F vect = new Vector3F(2.3f, 1.114124f, 0f);
    vect.x = Math.round(vect.x); // 2f
    vect.y = Math.round(vect.x); // 1f
    vect.z = Math.round(vect.x); // 0f
    

    2:

    // It will round the floats in Vector3F and leave the results as ints
    Vector3F vect = new Vector3F(2.3f, 1.114124f, 0f);
    int x = Math.round(vect.x);
    int y = Math.round(vect.x);
    int z = Math.round(vect.x);
    

    There is also more info: How to convert float to int with Java

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

Sidebar

Related Questions

I am currently making a small test program for simple file checking. The program
I am currently making a program which is supposed to prompt the user to
I am currently making a program that will send an email if the date
I'm currently making a PHP-program that solves equations. I've divided the input equation into
Currently making a global volunteer site, and the webpages will more or less have
I am currently making a program in which one of its functions is to
I am currently making a program in OpenGL 3.1, and I am using the
I'm currently making a small program to teach me some new Java, and I'm
I'm currently making a basic maths application in Android. Program will print on std
I am currently making an objective c program in which there are 4 shapes

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.