Mathematical Translations
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am building an API that will create walls and doors inside a custom family that acts somewhat as an empty area if you will. Since I cannot nest walls within the custom family, I have to create them via the API with (x,y,z) coordinates. When the user places the custom cube (area) family, the walls will get built. The issue is when the user selects a rotation that is not 0 deg, I do not know the translation of coordinates to assign to the wall start and end points. I have completed all the trig to determine the angles and it will account for any angle the user selects. How do I do the Mathematical translations to determine a formula which will help me determine the new start and end points of the walls? I have attached documents to show how I determined the angles using the Bounding Box Mins and Max along with the insertion point.
The knowns I have are:
User selected Length from UI
User selected Width from UI
User selected Insertion Point
Bounding Box Max Point
Bounding Box Min Point
Points pulled from this code:
BoundingBoxXYZ modBox = currMod.get_BoundingBox(doc.ActiveView);
XYZ modBoxMin = modBox.Min;
XYZ modBoxMax = modBox.Max;
startPoint = GetFamLocation(currMod);
//currMod is a custom family in the shape of a cube which I wish to build walls in but cannot due to not being able to nest system families.
Code used for trig:
string quadrant = "";
//------------QUADRANT I--------------//
if ((minXAbs <= 0) && (minYAbs >= 0) && (maxXAbs >= 0) && (maxYAbs >= 0))
{
quadrant = "Q1";
double ang01RAD = Math.Acos(Math.Abs(minXAbs) / massWidthDbl);
double ang01DEG = ang01RAD * (180 / Math.PI);
if (ang01RAD == 1)
ang01DEG = 0;
modAngle = Math.Floor(90 - ang01DEG);
}
//------------QUADRANT II--------------//
else if ((minXAbs <= 0) && (minYAbs <= 0) && (maxXAbs <= 0) && (maxYAbs >= 0))
{
quadrant = "Q2";
double ang01RAD = Math.Acos(Math.Abs(maxYAbs) / massLengthDblUR);
double ang01DEG = ang01RAD * (180 / Math.PI);
modAngle = Math.Floor(90 + ang01DEG);
}
//------------QUADRANT III--------------//
else if ((minXAbs <= 0) && (minYAbs <= 0) && (maxXAbs >= 0) && (maxYAbs <= 0))
{
quadrant = "Q3";
double ang01RAD = Math.Atan(minXAbs / minYAbs);
double ang01DEG = ang01RAD * (180 / Math.PI);
double ang01Cos = Math.Cos(ang01RAD);
double hyp = Math.Abs(minYAbs) / ang01Cos;
double ang02DEG = 90 - ang01DEG;
double ang03DEG = 90 - ang02DEG;
double ang03RAD = ang03DEG * (Math.PI / 180);
double ang03Sin = Math.Sin(ang03RAD);
double ang04Helper = (hyp * ang03Sin) / massLengthDbl;
double ang04suppRAD = Math.Asin(Math.Abs(ang04Helper));
double ang04suppDEG = ang04suppRAD * (180 / Math.PI);
double ang04DEG = 180 - ang04suppDEG;
double ang05DEG = 180 - ang04DEG - ang01DEG;
double ang06DEG = 90 - ang05DEG - ang01DEG;
modAngle = Math.Floor(180 + ang06DEG);
}
//------------QUADRANT IV--------------//
else if ((minXAbs >= 0) && (minYAbs <= 0) && (maxXAbs >= 0) && (maxYAbs >= 0))
{
if (quadrant != "Q1")
{
quadrant = "Q4";
double ang01RAD = Math.Acos(Math.Abs(minYAbs) / massLengthDbl);
double ang01DEG = ang01RAD * (180 / Math.PI);
modAngle = Math.Floor(270 + Math.Round(ang01DEG));
}