Jump to content

  • Log In with Google      Sign In   
  • Create Account


gretty

Member Since 27 Dec 2009
Offline Last Active Yesterday, 09:57 PM
-----

Posts I've Made

In Topic: Hash Distance & Angle To Produce Unique Value

Yesterday, 04:54 PM

Ok, after implementing the advice given to use Vector2's as keys I've got one last query/problem:

 

How should I go about handling angle wraparound?

 

For example; given the 2 points (DISTANCE, ANGLE):  A(100, 10) and B(100, 350). These 2 points are close by but will not be considered by operator comparision (<=, <, >=, >) to be close by.

 

Any ideas how I could handle this?


In Topic: Hash Distance & Angle To Produce Unique Value

Yesterday, 12:55 AM


you could just convert the distance + angle to an actual 2D point and go from there, it might be easier.

 

Wow, never though of that! A list of Vector2 where x = distance and y = angle may just work!! Thanks!

 

I can also do operator comparisions on Vector2's such as 'if v1 < v2' so that works nicely.


In Topic: Hash Distance & Angle To Produce Unique Value

Yesterday, 12:50 AM


What about multiplying the distance and the angle, suitably quantized, and handling angle wraparound properly?

 

Thanks for your reply. What do you mean by 'suitably quantized, and handling angle wraparound properly'?

 

If I multiply the angle and distance isn't that going to cause the same collisions? Like for a point with distance = 5 and angle = 10 resolves to 50 and a point with distance = 10 and angle = 5 also resolves to 50?


In Topic: Thinking in Javascript

Yesterday, 12:43 AM

I tend to learn programming easier by thinking up something I want to achieve then attempting to code it (and asking questions about 'How to do...' along the way) rather than reading books and doing exercises. Thats how I learnt/am learning Javascript. But this may not be how you learn.

 

But if you do, I'd try to do something like 'Move a div from the left of the screen to the right' or 'Get some XML from a server'.

 

Javascript is really powerful because there isn't quite anything called a class, yet you can still achieve sub-classing, polymorphism and abstraction.

 

An example is:

var someVariable= {"key": "value"}; // this a map

someVariable["Anonymous Function"] = new function(someParams) {
    consolelog(someParams);
};

// call anonymous function
someVariable["Anonymous Function"]("blah");

someVariable = [1, 2, 3]; // this is now an array

// I think you can do this also but may need to check
someVariable = {someProperty: 1.1};
console.log(someVariable.someProperty);  // almost treat the variable as a class with properties.



In Topic: Determine the 3d position of this vector

16 March 2014 - 07:12 PM

Thanks for the replies. You'll have to bear with me because for all the complex procedural programming concepts I understand, I struggle with mathematics.

 

If we take a step back; what I am trying to do is parallel a straight line segment. Therefore the point C will be one side of the paralleled line and I will create another point adjacent to B as the other point of that same paralleled line. Can you provide some advice on how I can parallel that straight line segment?

 

 

 


The problem is unsolvable with only two initial points, as this will produce a wheel of possible positions of C around A, remember this is 3D, so there exists infinite directions orthogonal to the vector (AB).

 

If I remove the 3d aspect, can you provide advice on how I can find point C's location and/or parallel a straight line segment in 2d? Is it simply a case of adding the offset(y value) to vector A? For eg:

Vector3 c = a + new Vector(y, 0, 0);  // y is the triangle length value from the OP picture
vector3 d = b + new Vector(y, 0, 0);

For the following line; if I use the above code wont that produce this result though?

af94lk.png    116l8b8.png

 

So I have to consider the 2d rotation aswell right?


PARTNERS