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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:24:52+00:00 2026-05-27T01:24:52+00:00

What are the pro’s and con’s of, for example, using a D3DXVECTOR3 (a directX

  • 0

What are the pro’s and con’s of, for example, using a D3DXVECTOR3 (a directX triple float) as opposed to using three floats in a function call.

so

Scale(D3DXVECTOR3(1, 1, 1));

as opposed to

Scale(1, 1, 1);

Is it better to use the second and only convert to a D3DXVECTOR3 when you need to use a library specific maths functions?

I also notice that many libraries have their own types for floats and doubles and so on. thoughts?

  • 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-27T01:24:52+00:00Added an answer on May 27, 2026 at 1:24 am

    One big reason to have APIs accept structures of floats instead of the floats themselves is readability. In any application using 3D graphics, you’re certainly going to have to work with lots of vectors. This is way more readable and maintainable:

    D3DXVECTOR Scale(D3DXVECTOR a, double scale)
    {
        return D3DXVECTOR(a.x * scale, a.y * scale, a.z * scale);
    }
    
    class MyClass
    {
    public:
        void DoSomething()
        {
            a = Scale(b, 2.0);
            ::D3DXVec3Cross(&out, &a, &b);
        }
    
    private:
        D3DXVECTOR3 out;
        D3DXVECTOR3 a;
        D3DXVECTOR3 b;
    };
    

    than this:

    class MyClass
    {
    public:
        void DoSomething()
        {
            float scale = 2.0;
            a1 = Scale(b1, scale);
            a2 = Scale(b2, scale);
            a3 = Scale(b3, scale);
            // Hypothetical D3DX function accepting floats directly
            ::D3DXVec3Cross(&out1, &out2, &out3, a1, a2, a3, b1, b2, b3);
        }
    
    private:
        float out1;
        float out2;
        float out3;
        float a1;
        float a2;
        float a3;
        float b1;
        float b2;
        float b3;
    };
    

    In other words, it allows for self-documenting code. Not to mention taking less time to type when you need to declare a vector (one D3DXVECTOR as opposed to three separate floats).

    That being said, typically a 3D graphics library/framework would define their own vector types and floating point types for portability across different platforms and configurations. One may simply define these types as follows:

    namespace My3DLib
    {
    
        typedef MyFloat float;
    
        struct MyVector
        {
            MyFloat x;
            MyFloat y;
            MyFloat z;
        };
    
        MyVector Scale(MyVector a, MyFloat b);
        MyFloat DotProduct(MyVector a, MyVector b);
        MyVector CrossProduct(MyVector a, MyVector b);
       // ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What are the pro's and con's of using Linq to SQL and core ADO.NET
I develop using MAMP pro on my Mac. When I start MAMP it prompts
I been using VS2008 Pro for a long time now but since of licensing
I am using MacBook Pro Mac OS 10.5 with related version of XCode. I
I am using MacBook Pro Mac OS 10.5 with related version of XCode. I
I am using MacBook Pro Mac OS 10.5 with related version of XCode. I
I am using MacBook Pro Mac OS 10.5 with related version of XCode. I
Background: Filemaker Pro 10+ have gained functionality to send emails using SendMail via SMTP.
After using IDA Pro to disassemble a x86 dll, I found this code (Comments
module PRO where average1 :: IO Float avarage1 = do putStrLn Enter Marks in

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.