My 3D Vector class

This is a discussion on My 3D Vector class within the C++ Programming forums, part of the General Programming Boards category; Lurker, clearly efficiency will be important for this class. For the most part, it looks good in that respect. In ...

  1. #16
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    Lurker, clearly efficiency will be important for this class. For the most part, it looks good in that respect. In your normalize function though, you may want to consider one call to length(), and storing the value in a temporary variable... It might be more efficient, might be less, I'm not entirely sure, but three function calls seems like a lot in that case.

    Anyways, nice class.

    Cheers
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  2. #17
    Banned
    Join Date
    Jan 2003
    Posts
    1,708
    post the source to your 3D game engine and show me where the info you posted was 100% necessary and most useful to solve a particular problem, because I can post mine and show you that the info you posted (which I went through and read) wasn't used at all (and, I might add, it's a pretty big engine at the moment). I know i came across as an ass, but for christ's sake do you think someone just writing their first vector class needs to be shown that stuff

  3. #18
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    I was rambling... I've got a test on that stuff tommorow, and I've been studying it for hours, hence the comment I made, "Anyways, not that any of that matters... I was just a bit bored."

    Edit: I've done very little graphics, but I can see that such info would not be useful (especially as efficiency is extremely important).

    My apologies... Truce?
    Last edited by Zach L.; 11-10-2003 at 09:34 PM.
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  4. #19
    Banned
    Join Date
    Jan 2003
    Posts
    1,708
    wish i was where you are, im taking freaking my first calculus class in high school, it's SO LAME

  5. #20
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    Yeah, I can understand that. If you ever get a chance, you might want to look into an abstract algebra course. Its not the most practical of math, but it certainly is fun.
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  6. #21
    Banned
    Join Date
    Jan 2003
    Posts
    1,708
    I'd honestly love to

  7. #22
    The Defective GRAPE Lurker's Avatar
    Join Date
    Feb 2003
    Posts
    949
    Originally posted by Zach L.
    Lurker, clearly efficiency will be important for this class. For the most part, it looks good in that respect. In your normalize function though, you may want to consider one call to length(), and storing the value in a temporary variable... It might be more efficient, might be less, I'm not entirely sure, but three function calls seems like a lot in that case.

    Anyways, nice class.

    Cheers
    Thanks . So you mean something as simple as this:

    Code:
    void Vector3D::normalize() {
     double temp = length();
     x /= temp;
     y /= temp;
     z /= temp;
    }
    Do not make direct eye contact with me.

  8. #23
    Registered User glUser3f's Avatar
    Join Date
    Aug 2003
    Posts
    345
    why double? I guess float would be more efficient for a 3D engine.

  9. #24
    The Defective GRAPE Lurker's Avatar
    Join Date
    Feb 2003
    Posts
    949
    If accuracy is needed, not necessarily.
    Do not make direct eye contact with me.

  10. #25
    Registered User glUser3f's Avatar
    Join Date
    Aug 2003
    Posts
    345
    I don't know, I have been into 3D programming for a while, read/done lots of stuff, and I hardly remember seeing something that used double for its calculations instead of float.
    Why not making it a template class? this way you can choose the type you need.

  11. #26
    The Defective GRAPE Lurker's Avatar
    Join Date
    Feb 2003
    Posts
    949
    Cause someone could put in string .
    Do not make direct eye contact with me.

  12. #27
    Banned
    Join Date
    Jan 2003
    Posts
    1,708
    float is accurate enough except in one case with collision detection, and even then i don't think double is accurate enough because i've never seen anybody effectively solve the problem by using double.

    i think using a template class for something as basic as this is a bad idea.

    floats are processed faster too

  13. #28
    Registered User glUser3f's Avatar
    Join Date
    Aug 2003
    Posts
    345
    a template class won't have any effect on performance, when compiling, the compiler generates different versions of the class depending on the types you used, but it won't affect the class performance.

  14. #29
    Banned
    Join Date
    Jan 2003
    Posts
    1,708
    ohh i wasn't getting at performance, it's just a retarded idea

  15. #30
    Banned
    Join Date
    Jan 2003
    Posts
    1,708
    if you use doubles you have to use doubles for everything, you can't use doubles and float and have them rely on each other.

    i.e
    for collision detection if you want super high precision using doubles then you absolutely have to have your position be represented by doubles, not floats, otherwise if you use doubles for the collision detection but then floats for your position then everything just gets casted to a float anyway and that precision would be lost.

Page 2 of 8 FirstFirst 12345678 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 3D Network Analysis Tool
    By durban in forum Projects and Job Recruitment
    Replies: 1
    Last Post: 11-08-2005, 05:33 PM
  2. A 3D Program for my 3D models...?
    By Rune Hunter in forum C++ Programming
    Replies: 26
    Last Post: 08-19-2004, 10:04 AM
  3. 3D starfield
    By VirtualAce in forum Game Programming
    Replies: 6
    Last Post: 06-26-2003, 12:40 PM
  4. 3D SDK for C++ programmers
    By chand in forum Game Programming
    Replies: 2
    Last Post: 05-20-2003, 07:38 AM
  5. 3d engines
    By Unregistered in forum Game Programming
    Replies: 7
    Last Post: 12-17-2001, 10:19 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21