How to add namespace to ScriptComponent?

unhandled

#1

I need to add the following namespace to a C# ScriptComponent (for prototyping)

System.Windows.Media.Media3D

How can I do that? The following syntax doesn’t work;

System.Windows.Media.Media3D.<methods>

I was trying to use Slerp. Any ideas?

// Rolf


#2

I found out that I should add the file PresentationCore.dll to my script component.

But then another problem occured, namely an ambiguous type (Transform) which seems to reside in that dll. I could fix all conflicting cases, except for a Transform in the method signature of the script component (not editable by the user).

Error (CS0104): ‘Transform’ is an ambiguous reference between ‘Rhino.Geometry.Transform’ and ‘System.Windows.Media.Transform’ (line 92)

Hm. Now what?

OK, I can bring in the Transform as a generic object instead (System.Object) and typecast it. (I’m documenting this so that others in similar trouble have a hint about how to workaround limitations like this)

bild

The dll for 0.9.0.76 is the v4.0.30319 version and can be found in

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\WPF\PresentationCore.dll

If the dll should be referenced from any other folder, please let me know.

// Rolf


(David Rutten) #3

Yup, it’s a nightmare, and there’s no easy way to wake up.

One (admittedly horrible) solution is to create a dll using Visual Studio which references the assembly you need and exposes some of the methodology, then reference that dll in your script.

But if you’re going down that route, you may as well create a full GHA project.


#4

Yes, I will move the script to VS later. For now I need it only for prototyping. Got it working with the hacks above.

But you’re wrong about the nightmare. It starts only when you wake up. :wink:

// Rolf


(Michael Pryor) #5

Would be interested to see the .Slerp in action.


(David Rutten) #6

#7

I got the dll’s loaded, but I still haven’t seen the Slerp slurping as expected. But I’m working on it. :wink:

In earlier tests Daniel Piker’s solution worked smoothly though, and it seemed to be perform some kind of gradual Slerp as well.

I’m messing around with some other problems at the same time, so I need to try some different approaches (doing some IK rotation via an external point (acting as a direction point for the final rotated plane), but so far it tends to flip the rotation plane of the object I’m trying to rotate).

Daniels smooth gradual plane-to-plane rotation:

Back to the lab.

// Rolf


(Michael Pryor) #8

Yea hes got some Quaternion splines going on.


(Daniel Piker) #9

Hi Rolf,
It sounds like it is more than SLERP you are after.
That will just let you do linear interpolation between a pair of orientations, same as you can already do with Rhinocommon by converting to axis-angle.
Doing this with a sequence of orientations is like a polyline in rotation space.
I think Shoemake’s SQUAD might be what you want, which is an interpolating spline in rotation space:
http://run.usc.edu/cs520-s13/assign2/p245-shoemake.pdf


(Michael Pryor) #10

Also SQUAD sounds cooler :smiley:


(Daniel Piker) #11

Agreed!

This page on the method in DirectX looks like a nice explanation:
https://msdn.microsoft.com/en-us/library/windows/desktop/bb281656(v=vs.85).aspx

So it uses this formula
Slerp(Slerp( q1 , c , t ), Slerp( a , b , t ), 2 t (1 - t ))

on 4 orientations (the a and b being the ones you are interpolating between, and q1 and c being there to keep the continuity with adjacent segments)

The description of this method shows how these 4 points are calculated
https://msdn.microsoft.com/en-us/library/windows/desktop/bb281657(v=vs.85).aspx


#12

Thank you @DanielPiker for the hints. I will read the links tonight.

To demosntrate what I am trying to achieve, I can show what I have. I have designed a component implementing an Ellipsoid (three radiuses) which I translate (externally via plane center) and rotate freely via a Transform inport (transforms shown in the clip below). Then in addition to that I have two main features:

#1: Rotating a vector, or point on the surface of that (freely rotated) ellipsoid, using Spherical coordinates (phi & theta inports). This is the white point which always stays on the surface.

#2. Same as above, but via rotating (or moving) an external point in 3D space, using the point as a direction (from the ellipsoid’s plane center to the external pt) and calculating the intersection point on the surface on (the translate-rotate-transformed) ellipsoid.

Messy? Yes, but I need this.

Fig.1. The ellipses inside this ellipsoid are there only to visualize the orientation of the ellipsoid:

Now, the clip shows that I have (numerical) control over any point or direction intersecting the ellipsoid surface, at any orientation of the ellipsoid, at all times. But now I want to add a third and most wanted feature:

#3. The external point should (not only define an intersection point on the surface of the ellispoid, but actually) rotate the ellipsoid given the initial plane (its initial rotation via the transform inport).

The desired end result would thus be an (IK) orientation of the Ellipsoid based on the, a) initial (inport) Transform + the b). “IK-rotation” derived from that nasty little external point being dragged around.

The only problem I have for now is that the final ellipsoid Plane tends to flip its axes when near parallel to the initial Plane’s axes, indicating that I have the wrong approach when creating the (IK) rotation end Plane.

// Rolf