Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
3 registered members (AndrewAMD, The_Judge, Grant), 898 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: Calling all TRIG nuts. Got a wobbley one for you! [Re: EvilSOB] #256229
03/15/09 13:33
03/15/09 13:33
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline OP
Expert
EvilSOB  Offline OP
Expert

Joined: Feb 2008
Posts: 3,232
Australia
That was easier than expected. I was trying to use draw_line using world co-ords instead of screen co-ords.
No wonder it looked weird...

Anyway, heres the NEW function, WORKING PERFECTLY based on spirits contribution.
It is NOW perfect, I discovered that if you allow the lerpfactor to go above
the 1.0 value, it will then extrapolate the line even if both point1 and point2
are on the same side of the Z-Plane.

FYI - By my testing, I believe I have concluded that:
A lerpfactor of =0 means point1 and point2 are parallel to the Z-plane. (bad!)
A lerpfactor of >0 means the z_plane in on the point2 'side' of point1
A lerpfactor of <0 means the z_plane in on the point1 'side' of point2
A lerpfactor of 0 to 1.0 means the z_plane is between point1 and point2 (useful to someone else?)
A lerpfactor of -1.0 to 0 means the z_plane is between point2 and point1 (useful to someone else?)

Anyways, sorry KDuke, but I've got what I wanted and its nice and small, as you can see below.
And HUGE thankings go out to my new best friend spirit, whose advice to others has aided me in the past,
but this is the first time youve helped me directly. My gratitudes kind sir...
Code:
action place_block()
{
	var Z_Offset = 180;	VECTOR p1, p2;
	while(me)
	{
		vec_set(p1, vector(mouse_pos.x,mouse_pos.y, 1));	vec_for_screen(p1,camera);
		vec_set(p2, vector(mouse_pos.x,mouse_pos.y,10));	vec_for_screen(p2,camera);
		if(p1.z!=p2.z)		vec_lerp(me.x,p1,p2,-p1.z/(p2.z-p1.z));
		me.z = Z_Offset;
		wait(1);
	}
}

CASE CLOSED - For me anyway.


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Calling all TRIG nuts. Got a wobbley one for you! [Re: EvilSOB] #256230
03/15/09 13:38
03/15/09 13:38
Joined: Mar 2009
Posts: 112
Germany
K
KDuke Offline
Member
KDuke  Offline
Member
K

Joined: Mar 2009
Posts: 112
Germany
The version with lerp is surely much better.

Now I as well finally see why vec_lerp can be used for this.
I thought interpolating always gets you a value between values.
Though the value resulting from interpolation does not neccessarily have to be in the range of the two given values.

Because I didn't know before is the reason why I pulled the mathemathical cudgel.

EDIT:
By the way. It's no problem. This forum is to share knowledge not to battle who might help someone better ;-)

Last edited by KDuke; 03/15/09 13:42.

Using A7 Free
Click and join the 3dgs irc community!
Room: #3dgs
Re: Calling all TRIG nuts. Got a wobbley one for you! [Re: KDuke] #256232
03/15/09 14:18
03/15/09 14:18
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline OP
Expert
EvilSOB  Offline OP
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Just wanted you to know I AM gratful for your help, even though I never used it...


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Calling all TRIG nuts. Got a wobbley one for you! [Re: EvilSOB] #256677
03/18/09 09:33
03/18/09 09:33
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline OP
Expert
EvilSOB  Offline OP
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Tobias or Spirit, Im back Im afraid...
Code IS working perfectly, but unfortunately my reuirements have changed.
Can someone please supply me (preferably with an explanation) with a variation
of this lerpfactor formula, that find the point where the Z-plane is crossed.
var lerpfactor = -p1.z/(p2.z - p1.z);

The variation (and explanation) I need is this. I want to find the lerpfactor
when the line crosses the Z-Plane WHERE Z = XX. Where XX is a + or - value.
Also, XX needs to be a variable and its value will change from time to time.

[EDIT] After a bit of playing, it appears to be
var lerpfactor = (-p1.z+XX)/(p2.z - p1.z);
But I would link some verification if possible...


Thanks guys.



"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Calling all TRIG nuts. Got a wobbley one for you! [Re: EvilSOB] #256823
03/19/09 08:57
03/19/09 08:57
Joined: Aug 2000
Posts: 1,140
Baunatal, Germany
Tobias Offline

Moderator
Tobias  Offline

Moderator

Joined: Aug 2000
Posts: 1,140
Baunatal, Germany
Yes your formula is right, the lerp factor is just the ratio of the z distance of the first point, to the overall z distance. Thats (XX-p1.z)/(p2.z-p1.z), and if XX is 0 you get the original formula.

Re: Calling all TRIG nuts. Got a wobbley one for you! [Re: Tobias] #256829
03/19/09 09:06
03/19/09 09:06
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline OP
Expert
EvilSOB  Offline OP
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Kewl, many thanks...


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Page 2 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1