# altra4u

Members

50

122 Neutral

• Rank
Member
1. ## Most efficient way to do front-back test

oh yea. the projection of one vector onto another should be good enough. Lol, y didnt I think of that. Thats y we have the forums i guess. Thank u sir Bacterius.
2. ## Most efficient way to do front-back test

Hi Guys I was wondering what would be the least expensive way of saying here is my character facing this direction and I want to return a boolean for other characters if they are within a 180 degree curve in front of me. I can think of doing a dot product between my front vector, V1, and vector from target to me, V2, but that will involve a doing a square root operation in finding the length of V2 so I was thinking what others have to say. Thoughts welcome. Thanks.
3. ## Re:Distance to target check

Basically I have distance^2, range^2 and radius of each character and I want to keep it the most optimized. Looks like its going to have to be d - r < range check.
4. ## Re:Distance to target check

Good suggestion. Do you think its worth doing this addition and multiplication operations over doing square root of distance though? Plus I will either have radius or radius^2. So if I have radius then I will have to square it and if I have radius^2 then I will have to root it. lol. Or I would have to save both. Probably not a good idea to double data storage.
5. ## Re:Distance to target check

Hi So normally a distance check would be done by simply doing distance < range check. So lets say distance between character a from character b. However to optimize one would do d^2 < r^2 check. However if one has to include the radius of each of the characters then the check would be distance - characterradii < range where characterradii = raidusofa + radiusofb I'm trying to think of some way where I could keep the squared optimization and also be able to include the radii part. Thoughts?? I'm discounting this one (d^2 - r^2)/(d+r) as that will need the square root value of d Thanks.
6. ## Positioning camera to see mentioned points

@[url="user/155219-szecs/"]szecs[/url] My camera is defined as an object that could be translated and rotated. The problem is I don't really have access to the camera's view frustum settings. All I can do is zoom in and out. That works for player controlled camera where he would like to zoom in and out but I'm having trouble automating the zoom to have the proper view frustum. To begin with need not be that accurate. If the points had to move, I would simply put the logic in game loop. To start with I would just like to have the camera look straight at the points(lets say they were in the same vertical plane). @Emergent. Yes this is like a 2d problem No obstacles or anything. I'll try messing with your suggested solution. Thanks
7. ## Most efficient way to do facing test

@apatriarca However wont u think that calculating sin from cos or cos from sin using the sin^2 + cos^2 = 1 property will be more expensive that an arccosine, which is wat I'm doing right now?
8. ## Most efficient way to do facing test

@[url="user/105019-apatriarca/"]apatriarca[/url] yea should have thought about that. I'm using the engine's external functions for rotation so kinda skipped my mind. I should do that rotation logic myself. [b] [url="user/146856-taz0010/"]@taz0010[/url][/b] I think you misunderstood my last question. After asking on how to most efficiently do facing test, I asked what would be the most efficient way to align my front vector to face an object. I'm using cross product to find out if its a clockwise or anti-clockwise rotation.
9. ## Positioning camera to see mentioned points

Bumpity bump...anyone plz?
10. ## Most efficient way to do facing test

But if I don't know the angle how can I say rotate my front vector by this much to face the target?
11. ## Most efficient way to do facing test

[quote name='alvaro' timestamp='1310581792' post='4834940'] [quote name='altra4u' timestamp='1310534863' post='4834631'] Yea I agree that its for 2D. Also remember the posts on arctan being slower than squareroot operation and all that. Not sure about the code messy part. How would it make it messy as compared to what otherwise I would do? Hey here's also an important note on arctan as mentioned on [url="http://en.wikipedia.org/wiki/Inverse_trigonometric_functions"]http://en.wikipedia....etric_functions[/url] [/quote] The messy part is that the angles 170 degree and -175 degree are only 15 degrees apart, and checking that type of thing is cumbersome and error prone. It's not horrible, but I don't like to deal with it. [quote]Read the Practical Considerations part. I guess I'll have to test and use the other alternatives, see if they work for me, otherwise use arctan2. Its just that I don't know how arctan2 works under the hood. I'm finding it hard to believe arctan2 is more expensive than doing the whole dot product and normalize thing.[/quote] Of course you should implement it both ways and compare, but I have a strong expectation that atan2 will be slower. As a general recommendation, I would try to stay away from using angles. Although most people find them very intuitive initially, especially in 2D, once you get familiar with the dot product you don't need them, and the angle-free code is usually shorter, faster to execute, more general (3D as well as 2D) and easier to get right. [/quote] Thanks for your inputs alvaro. I think I'll have to use angles though cause I'm trying to point to an object. Don't see a way using simply dot product.
12. ## Positioning camera to see mentioned points

Hi Lets say I have 3 points I want to make sure are included in the camera's vision frustum. How can I ensure that the camera is placed at the most optimal position closest to the points but far enough to be able to see all of them together? Thanks
13. ## Most efficient way to do facing test

Yea I agree that its for 2D. Also remember the posts on arctan being slower than squareroot operation and all that. Not sure about the code messy part. How would it make it messy as compared to what otherwise I would do? Hey here's also an important note on arctan as mentioned on http://en.wikipedia.org/wiki/Inverse_trigonometric_functions Read the Practical Considerations part. I guess I'll have to test and use the other alternatives, see if they work for me, otherwise use arctan2. Its just that I don't know how arctan2 works under the hood. I'm finding it hard to believe arctan2 is more expensive than doing the whole dot product and normalize thing. Thanks for all your inputs.
14. ## Most efficient way to do facing test

why not? I'm thinking like atan2(target.z - my.z / target.x - my.x) will give me an angle that I should be able to use. no? Thanks
15. ## Most efficient way to do facing test

I'm not sure why people are not mentioning arctan2 at all??? I believed that was the most efficient way to go and since I didn't have in-depth knowledge on it I was hoping a math maestro would come along and explain