Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VIS 6783 Add short Frame3f constructor #50

Merged
merged 1 commit into from
Jul 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions math/Frame3f.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Text;
using System.Diagnostics;
using g3;
using System.Globalization;

namespace g3
{
Expand Down Expand Up @@ -68,6 +69,12 @@ public Frame3f(Vector3f origin, Vector3f x, Vector3f y, Vector3f z)
this.rotation = m.ToQuaternion();
}

public Frame3f(double x, double y, double z, double rx, double ry, double rz, double rw)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you cast double to float either way, wouldn't it be easier to just accept floats in constructor?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sadly, I usually use double, and, then, to call it, I would need to write new Frame3f((float)0.5, ...) or new Frame3f(0.5f, ...). Both are waste of time

{
this.origin = new Vector3f((float)x, (float)y, (float)z);
this.rotation = new Quaternionf((float)rx, (float)ry, (float)rz, (float)rw);
}


public Quaternionf Rotation
{
Expand Down Expand Up @@ -448,10 +455,17 @@ public readonly bool EpsilonEqual(Frame3f f2, float epsilon) {
rotation.EpsilonEqual(f2.rotation, epsilon);
}


public override readonly string ToString() {
return ToString("F4");
public readonly string ToShortString() {
string xString = origin.x.ToString("F4", CultureInfo.InvariantCulture);
string yString = origin.y.ToString("F4", CultureInfo.InvariantCulture);
string zString = origin.z.ToString("F4", CultureInfo.InvariantCulture);
string rxString = rotation.x.ToString("F4", CultureInfo.InvariantCulture);
string ryString = rotation.y.ToString("F4", CultureInfo.InvariantCulture);
string rzString = rotation.z.ToString("F4", CultureInfo.InvariantCulture);
string rwString = rotation.w.ToString("F4", CultureInfo.InvariantCulture);
return string.Join(", ", xString, yString, zString, rxString, ryString, rzString, rwString);
}

public readonly string ToString(string fmt) {
return string.Format("[Frame3f: Origin={0}, X={1}, Y={2}, Z={3}]", Origin.ToString(fmt), X.ToString(fmt), Y.ToString(fmt), Z.ToString(fmt));
}
Expand Down
Loading